Fix language nesting problem with polyglossia

Part (?) of #9633
This commit is contained in:
Juergen Spitzmueller 2015-06-19 09:25:11 +02:00
parent 8b36c090b7
commit b1c68dccf8

View File

@ -58,12 +58,13 @@ enum OpenEncoding {
struct OutputState struct OutputState
{ {
OutputState() : open_encoding_(none), cjk_inherited_(0), OutputState() : open_encoding_(none), cjk_inherited_(0),
prev_env_language_(0) prev_env_language_(0), open_polyglossia_lang_("")
{ {
} }
int open_encoding_; int open_encoding_;
int cjk_inherited_; int cjk_inherited_;
Language const * prev_env_language_; Language const * prev_env_language_;
string open_polyglossia_lang_;
}; };
@ -968,6 +969,10 @@ void TeXOnePar(Buffer const & buf,
unskip_newline = !localswitch; unskip_newline = !localswitch;
} }
} else if (!par_lang.empty()) { } else if (!par_lang.empty()) {
// 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( os << from_ascii(subst(
lang_end_command, lang_end_command,
"$$lang", "$$lang",
@ -977,6 +982,7 @@ void TeXOnePar(Buffer const & buf,
} }
} }
} }
}
if (closing_rtl_ltr_environment) if (closing_rtl_ltr_environment)
os << "}"; os << "}";
@ -1254,6 +1260,11 @@ void latexParagraphs(Buffer const & buf,
os << "\\end{CJK}\n"; os << "\\end{CJK}\n";
state->open_encoding_ = none; 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 // reset inherited encoding
if (state->cjk_inherited_ > 0) { if (state->cjk_inherited_ > 0) {