]> git.lyx.org Git - lyx.git/commitdiff
Fix #10778 (issue with CJK and language nesting)
authorEnrico Forestieri <forenr@lyx.org>
Thu, 2 Nov 2017 09:35:58 +0000 (10:35 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 2 Nov 2017 10:07:11 +0000 (11:07 +0100)
When using CJK, don't try to close a language that was never
opened before, such as when it is the main language.

(cherry picked from commit 7e51b5f30196fa0679a7c3c32dc75bca91520f32)

src/Paragraph.cpp
src/output_latex.cpp
src/output_latex.h

index 859896900f315096b027f2b82cf51403fda337d9..6f514863de831fb780cfc3cfe027406bd92835e2 100644 (file)
@@ -2542,6 +2542,7 @@ void Paragraph::latex(BufferParams const & bparams,
                bool const using_begin_end = runparams.use_polyglossia ||
                                                !lang_end_command.empty();
                if (!running_lang.empty() &&
+                   (!using_begin_end || running_lang == openLanguageName()) &&
                    current_font.language()->encoding()->package() == Encoding::CJK) {
                                string end_tag = subst(lang_end_command,
                                                        "$$lang",
index 02667aae9f69b6ae24367f3ade9b00a241eaa7b7..1431bbb321254fa7e32da97211f3806401b09196 100644 (file)
@@ -532,6 +532,14 @@ void popLanguageName()
 }
 
 
+string const & openLanguageName()
+{
+       OutputState * state = getOutputState();
+
+       return openLanguageName(state);
+}
+
+
 namespace {
 
 void addArgInsets(Paragraph const & par, string const & prefix,
index 0969d22c03b91baec50f6bc616bd92f7981fac14..1dd96898511e3ea078d715a11db7460d87db3988 100644 (file)
@@ -39,6 +39,13 @@ void pushLanguageName(std::string const & lang, bool localswitch = false);
  */
 void popLanguageName();
 
+/** Return a reference to the last active language opened with
+    polyglossia or when using begin/end commands. If none or when
+    using babel with only a begin command, return a reference to
+    an empty string.
+ */
+std::string const & openLanguageName();
+
 /** Export optional and required arguments of the paragraph \p par.
     Non-existing required arguments are output empty: {}.
  */