From b1c68dccf8f920b97a8bd23f2c9ba60eeb7fdaf5 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 19 Jun 2015 09:25:11 +0200 Subject: [PATCH] Fix language nesting problem with polyglossia Part (?) of #9633 --- src/output_latex.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/output_latex.cpp b/src/output_latex.cpp index d8b1d0b7bd..fdfe7f83e7 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -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) { -- 2.39.2