luabidi's \\LR[E] needs to be embraced (possibly a LuaTeX bug)

without the grouping, trailing text disappears
This commit is contained in:
Juergen Spitzmueller 2023-04-10 15:16:20 +02:00
parent 2abde5d162
commit 8917cb3cc8
2 changed files with 21 additions and 10 deletions

View File

@ -435,8 +435,10 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
|| language()->lang() == "arabic_arabi")) { || language()->lang() == "arabic_arabi")) {
if (runparams.use_polyglossia) { if (runparams.use_polyglossia) {
// LuaTeX/luabidi // LuaTeX/luabidi
os << "\\LR{"; // \LR needs extra grouping
count += 5; // (possibly a LuaTeX bug)
os << "{\\LR{";
count += 6;
} else { } else {
os << "{\\beginL "; os << "{\\beginL ";
count += 9; count += 9;
@ -610,8 +612,10 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
|| language()->lang() == "arabic_arabi")) { || language()->lang() == "arabic_arabi")) {
if (runparams.use_polyglossia) { if (runparams.use_polyglossia) {
// LuaTeX/luabidi // LuaTeX/luabidi
os << "}"; // luabidi's \LR needs extra grouping
count += 1; // (possibly a LuaTeX bug)
os << "}}";
count += 2;
} else { } else {
os << "\\endL}"; os << "\\endL}";
count += 6; count += 6;

View File

@ -1090,7 +1090,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
running_change = Change(Change::UNCHANGED); running_change = Change(Change::UNCHANGED);
} }
bool close_brace = false; unsigned int close_brace = 0;
bool const disp_env = (inset->isEnvironment() && inset->getLayout().isDisplay()) bool const disp_env = (inset->isEnvironment() && inset->getLayout().isDisplay())
|| runparams.inDisplayMath; || runparams.inDisplayMath;
string close_env; string close_env;
@ -1108,19 +1108,25 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
os << "\\begin{LTR}"; os << "\\begin{LTR}";
close_env = "LTR"; close_env = "LTR";
} else { } else {
if (runparams.flavor == Flavor::LuaTeX) {
// luabidi's \LRE needs extra grouping
// (possibly a LuaTeX bug)
os << '{';
close_brace = 1;
}
os << "\\LRE{"; os << "\\LRE{";
close_brace = true; close_brace += 1;
} }
} else if (running_font.language()->lang() == "farsi" } else if (running_font.language()->lang() == "farsi"
|| running_font.language()->lang() == "arabic_arabi") { || running_font.language()->lang() == "arabic_arabi") {
os << "\\textLR{" << termcmd; os << "\\textLR{" << termcmd;
close_brace = true; close_brace = 1;
} else { } else {
// babel classic // babel classic
os << "\\L{"; os << "\\L{";
if (disp_env) if (disp_env)
os << safebreakln; os << safebreakln;
close_brace = true; close_brace = 1;
} }
} }
@ -1201,8 +1207,9 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
if (!close_env.empty()) if (!close_env.empty())
os << "\\end{" << close_env << "}"; os << "\\end{" << close_env << "}";
if (close_brace) { if (close_brace > 0) {
os << '}'; for (unsigned i = 0; i < close_brace; ++i)
os << '}';
if (disp_env) if (disp_env)
os << safebreakln; os << safebreakln;
} }