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
{
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,6 +969,10 @@ void TeXOnePar(Buffer const & buf,
unskip_newline = !localswitch;
}
} 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(
lang_end_command,
"$$lang",
@ -977,6 +982,7 @@ void TeXOnePar(Buffer const & buf,
}
}
}
}
if (closing_rtl_ltr_environment)
os << "}";
@ -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) {