]> git.lyx.org Git - lyx.git/commitdiff
Correctly set language after intitle paragraphs
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 16 Aug 2019 14:24:09 +0000 (16:24 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 20 Aug 2019 06:37:37 +0000 (08:37 +0200)
Fixes: #11514
(cherry picked from commit b5722962fb0393299e02df0b146522770e98aef6)

src/output_latex.cpp
status.23x

index b402eb934b20b1d2f1b0ced682d5e5e60f2e7a63..24e5b7fb819d661511d4321c3b4288ab83f4c736 100644 (file)
@@ -806,11 +806,30 @@ void TeXOnePar(Buffer const & buf,
                        && (priorpar->getDepth() > par.getDepth()
                            || (priorpar->getDepth() == par.getDepth()
                                    && priorpar->layout() != par.layout()));
+
+       // We need to ignore previous intitle commands since languages
+       // are switched locally there (# 11514)
+       // There might be paragraphs before the title, so we check this.
+       Paragraph * prior_nontitle_par = nullptr;
+       if (!intitle_command) {
+               pit_type ppit = pit;
+               while (ppit > 0) {
+                       --ppit;
+                       Paragraph const * tmppar = &paragraphs.at(ppit);
+                       if (tmppar->layout().intitle && tmppar->layout().isCommand())
+                               continue;
+                       prior_nontitle_par = const_cast<Paragraph*>(tmppar);
+                       break;
+               }
+       }
        Language const * const prev_language =
-               (priorpar && !priorpar->isPassThru())
-               ? (use_prev_env_language ? state->prev_env_language_
-                                        : priorpar->getParLanguage(bparams))
-               : outer_language;
+               runparams_in.for_search 
+                       ? languages.getLanguage("ignore")
+                       : (prior_nontitle_par && !prior_nontitle_par->isPassThru())
+                               ? (use_prev_env_language 
+                                       ? state->prev_env_language_
+                                       : prior_nontitle_par->getParLanguage(bparams))
+                               : outer_language;
 
        bool const use_polyglossia = runparams.use_polyglossia;
        string const par_lang = use_polyglossia ?
@@ -927,7 +946,7 @@ void TeXOnePar(Buffer const & buf,
                        }
                        // With CJK, the CJK tag has to be closed first (see below)
                        if (runparams.encoding->package() != Encoding::CJK
-                           && (par_lang != openLanguageName(state) || localswitch)
+                           && (par_lang != openLanguageName(state) || localswitch || intitle_command)
                            && !par_lang.empty()) {
                                string bc = use_polyglossia ?
                                          getPolyglossiaBegin(lang_begin_command, par_lang,
index b435fa1e245b3ebfbf43280ec442f2f8338c5663..61f3d0d09e4b0b3843bef6f3f46a896ff0c7158e 100644 (file)
@@ -61,6 +61,8 @@ What's new
 - (Re-)fix problems with activated equal sign and graphic options in Turkish
   and Latin documents (bug 2005).
 
+- Correctly set language after intitle paragraphs (bug 11514).
+
 - Fix toprule with booktabs/longtable and captions (bug 11589).
 
 - Avoid adding spaces when parsing an array in a macro template (bug 10499).