Close/reopen local language switches at each par

Fixes: #11128
This commit is contained in:
Juergen Spitzmueller 2018-04-27 09:48:14 +02:00
parent 90cfe4ec3b
commit f778870338

View File

@ -839,22 +839,22 @@ void TeXOnePar(Buffer const & buf,
lang_command_termination.clear(); lang_command_termination.clear();
} }
if (par_lang != prev_lang // localswitches need to be closed and reopened at each par
// check if we already put language command in TeXEnvironment() if ((par_lang != prev_lang || localswitch)
&& !(style.isEnvironment() // check if we already put language command in TeXEnvironment()
&& (pit == 0 || (priorpar->layout() != par.layout() && !(style.isEnvironment()
&& priorpar->getDepth() <= par.getDepth()) && (pit == 0 || (priorpar->layout() != par.layout()
|| priorpar->getDepth() < par.getDepth()))) && priorpar->getDepth() <= par.getDepth())
{ || priorpar->getDepth() < par.getDepth()))) {
if ((!using_begin_end || langOpenedAtThisLevel(state)) && if (!localswitch
!lang_end_command.empty() && && (!using_begin_end || langOpenedAtThisLevel(state))
prev_lang != outer_lang && && !lang_end_command.empty()
!prev_lang.empty() && && prev_lang != outer_lang
(!using_begin_end || !style.isEnvironment())) && !prev_lang.empty()
{ && (!using_begin_end || !style.isEnvironment())) {
os << from_ascii(subst(lang_end_command, os << from_ascii(subst(lang_end_command,
"$$lang", "$$lang",
prev_lang)) prev_lang))
<< lang_command_termination; << lang_command_termination;
if (using_begin_end) if (using_begin_end)
popLanguageName(); popLanguageName();
@ -1115,7 +1115,8 @@ void TeXOnePar(Buffer const & buf,
&&((nextpar && par_lang != nextpar_lang) &&((nextpar && par_lang != nextpar_lang)
|| (runparams.isLastPar && par_lang != outer_lang)); || (runparams.isLastPar && par_lang != outer_lang));
if ((intitle_command && using_begin_end) if (localswitch
|| (intitle_command && using_begin_end)
|| closing_rtl_ltr_environment || closing_rtl_ltr_environment
|| ((runparams.isLastPar || close_lang_switch) || ((runparams.isLastPar || close_lang_switch)
&& (par_lang != outer_lang || (using_begin_end && (par_lang != outer_lang || (using_begin_end
@ -1125,7 +1126,7 @@ void TeXOnePar(Buffer const & buf,
// we need to reset the language at the end of footnote or // we need to reset the language at the end of footnote or
// float. // float.
if (pending_newline || close_lang_switch) if (!localswitch && (pending_newline || close_lang_switch))
os << '\n'; os << '\n';
// when the paragraph uses CJK, the language has to be closed earlier // when the paragraph uses CJK, the language has to be closed earlier