From: Juergen Spitzmueller Date: Mon, 10 Apr 2023 13:16:20 +0000 (+0200) Subject: luabidi's \\LR[E] needs to be embraced (possibly a LuaTeX bug) X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8917cb3cc880452dfbae9475b14ddb2ba58780ab;p=features.git luabidi's \\LR[E] needs to be embraced (possibly a LuaTeX bug) without the grouping, trailing text disappears --- diff --git a/src/Font.cpp b/src/Font.cpp index 0e4aa2b24b..e072bca5b5 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -435,8 +435,10 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams, || language()->lang() == "arabic_arabi")) { if (runparams.use_polyglossia) { // LuaTeX/luabidi - os << "\\LR{"; - count += 5; + // \LR needs extra grouping + // (possibly a LuaTeX bug) + os << "{\\LR{"; + count += 6; } else { os << "{\\beginL "; count += 9; @@ -610,8 +612,10 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams, || language()->lang() == "arabic_arabi")) { if (runparams.use_polyglossia) { // LuaTeX/luabidi - os << "}"; - count += 1; + // luabidi's \LR needs extra grouping + // (possibly a LuaTeX bug) + os << "}}"; + count += 2; } else { os << "\\endL}"; count += 6; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 3ec79d5c33..b8819fdf1b 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1090,7 +1090,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, running_change = Change(Change::UNCHANGED); } - bool close_brace = false; + unsigned int close_brace = 0; bool const disp_env = (inset->isEnvironment() && inset->getLayout().isDisplay()) || runparams.inDisplayMath; string close_env; @@ -1108,19 +1108,25 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, os << "\\begin{LTR}"; close_env = "LTR"; } else { + if (runparams.flavor == Flavor::LuaTeX) { + // luabidi's \LRE needs extra grouping + // (possibly a LuaTeX bug) + os << '{'; + close_brace = 1; + } os << "\\LRE{"; - close_brace = true; + close_brace += 1; } } else if (running_font.language()->lang() == "farsi" || running_font.language()->lang() == "arabic_arabi") { os << "\\textLR{" << termcmd; - close_brace = true; + close_brace = 1; } else { // babel classic os << "\\L{"; if (disp_env) os << safebreakln; - close_brace = true; + close_brace = 1; } } @@ -1201,8 +1207,9 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, if (!close_env.empty()) os << "\\end{" << close_env << "}"; - if (close_brace) { - os << '}'; + if (close_brace > 0) { + for (unsigned i = 0; i < close_brace; ++i) + os << '}'; if (disp_env) os << safebreakln; }