]> git.lyx.org Git - features.git/commitdiff
Fix language nesting problem with polyglossia
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 19 Jun 2015 07:25:11 +0000 (09:25 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Fri, 19 Jun 2015 07:25:11 +0000 (09:25 +0200)
Part (?) of #9633

src/output_latex.cpp

index d8b1d0b7bd77b81897741bf3a69efd5413ba524a..fdfe7f83e7ff266d72a1eb00a003ba595e5afe23 100644 (file)
@@ -58,12 +58,13 @@ enum OpenEncoding {
 struct OutputState
 {
        OutputState() : open_encoding_(none), cjk_inherited_(0),
-                       prev_env_language_(0)
+                       prev_env_language_(0), open_polyglossia_lang_("")
        {
        }
        int open_encoding_;
        int cjk_inherited_;
        Language const * prev_env_language_;
+       string open_polyglossia_lang_;
 };
 
 
@@ -968,12 +969,17 @@ void TeXOnePar(Buffer const & buf,
                                        unskip_newline = !localswitch;
                                }
                        } else if (!par_lang.empty()) {
-                               os << from_ascii(subst(
-                                       lang_end_command,
-                                       "$$lang",
-                                       par_lang));
-                               pending_newline = !localswitch;
-                               unskip_newline = !localswitch;
+                               // If we are in an environment, we have to close the language afterwards
+                               if (style.isEnvironment())
+                                       state->open_polyglossia_lang_ = par_lang;
+                               else {
+                                       os << from_ascii(subst(
+                                               lang_end_command,
+                                               "$$lang",
+                                               par_lang));
+                                       pending_newline = !localswitch;
+                                       unskip_newline = !localswitch;
+                               }
                        }
                }
        }
@@ -1254,6 +1260,11 @@ void latexParagraphs(Buffer const & buf,
                os << "\\end{CJK}\n";
                state->open_encoding_ = none;
        }
+       // Likewise for polyglossia
+       if (maintext && !is_child && state->open_polyglossia_lang_ != "") {
+               os << "\\end{" << state->open_polyglossia_lang_ << "}\n";
+               state->open_polyglossia_lang_ = "";
+       }
 
        // reset inherited encoding
        if (state->cjk_inherited_ > 0) {