Am Sonntag, dem 02.04.2023 um 13:21 +0200 schrieb Jürgen Spitzmüller: > This needs some effort. For the time being, I think we will be better > off with this rather harmless info message.
Possible approach attached. -- Jürgen
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index c43421b376..46b79837d3 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1090,7 +1090,8 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, running_change = Change(Change::UNCHANGED); } - bool close = false; + bool close_brace = false; + string close_env; odocstream::pos_type const len = os.os().tellp(); if (inset->forceLTR(runparams) @@ -1101,16 +1102,24 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, // ERT is an exception, it should be output with no // decorations at all && inset->lyxCode() != ERT_CODE) { - if (runparams.use_polyglossia) + if (runparams.use_polyglossia) { // (lua)bidi - os << "\\LRE{"; - else if (running_font.language()->lang() == "farsi" - || running_font.language()->lang() == "arabic_arabi") + if (inset->isEnvironment()) { + os << "\\begin{LTR}"; + close_env = "LTR"; + } else { + os << "\\LRE{"; + close_brace = true; + } + } else if (running_font.language()->lang() == "farsi" + || running_font.language()->lang() == "arabic_arabi") { os << "\\textLR{" << termcmd; - else + close_brace = true; + } else { // babel classic os << "\\L{"; - close = true; + close_brace = true; + } } if (open_font && fontswitch_inset) { @@ -1187,7 +1196,10 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, throw; } - if (close) + if (!close_env.empty()) + os << "\\end{" << close_env << "}"; + + if (close_brace) os << '}'; if (os.texrow().rows() > previous_row_count) { diff --git a/src/insets/Inset.h b/src/insets/Inset.h index fd55d69215..fa9214d705 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -15,6 +15,7 @@ #ifndef INSETBASE_H #define INSETBASE_H +#include "InsetLayout.h" #include "ColorCode.h" #include "InsetCode.h" #include "LayoutEnums.h" @@ -601,6 +602,8 @@ public: virtual void acceptChanges() {} /// reject the changes within the inset virtual void rejectChanges() {} + /// + virtual bool isEnvironment() const { return getLayout().latextype() == InsetLaTeXType::ENVIRONMENT; } /// virtual bool needsCProtection(bool const, bool const) const { return false; } diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 9d4eeb1d44..080b7b7882 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -38,6 +38,8 @@ public: static void string2params(std::string const &, InsetListingsParams &); /// static std::string params2string(InsetListingsParams const &); + /// + bool isEnvironment() const { return !params().isInline(); } private: /// bool isLabeled() const override { return true; }
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel