From aa9fed932225bb9344a056df3610258f19fa94dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Fri, 22 Jun 2012 03:41:00 +0200 Subject: [PATCH] - tex2lyx/text.cpp: - bugfix for the parsing of polyglossia's paragraph environments - new support for polyglossia's language change commands \textxxx - XeTeX-polyglossia.tex: add more testcases and add a missing \end --- src/tex2lyx/test/XeTeX-polyglossia.tex | 10 ++++++++-- src/tex2lyx/text.cpp | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/tex2lyx/test/XeTeX-polyglossia.tex b/src/tex2lyx/test/XeTeX-polyglossia.tex index 3ea7c1e53a..49d2e512c6 100644 --- a/src/tex2lyx/test/XeTeX-polyglossia.tex +++ b/src/tex2lyx/test/XeTeX-polyglossia.tex @@ -13,13 +13,13 @@ \part{df} -1 +1 Coptic \textgreek{Greek} Coptic \begin{albanian}% \part{df} -2 +2 Albanian \textgreek{Greek} Albanian \end{albanian}% \begin{divehi}% @@ -41,4 +41,10 @@ \part{df} 5 +\end{divehi}% + +%empty language paragraph +\begin{albanian}% +\end{albanian}% + \end{document} diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 55e964c7f5..92934cce94 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1252,9 +1252,20 @@ void parse_environment(Parser & p, ostream & os, bool outer, } else if (is_known(name, polyglossia_languages)) { - parent_context.check_layout(os); + // We must begin a new paragraph if not already done + if (! parent_context.atParagraphStart()) { + parent_context.check_end_layout(os); + parent_context.new_paragraph(os); + } + // save the language for the case that a + // \textLANGUAGE is used parent_context.font.language = polyglossia2lyx(name); os << "\n\\lang " << parent_context.font.language << "\n"; + parse_text(p, os, FLAG_END, outer, parent_context); + // Just in case the environment is empty + parent_context.extra_stuff.erase(); + // We must begin a new paragraph to reset the language + parent_context.new_paragraph(os); p.skip_spaces(); } @@ -3457,6 +3468,14 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, context, "\\lang", context.font.language, lang); } + + else if (is_known(t.cs().substr(4, string::npos), polyglossia_languages)) { + // scheme is \textLANGUAGE{text} where LANGUAGE is in polyglossia_languages[] + string const lang = polyglossia2lyx(t.cs().substr(4, string::npos)); + parse_text_attributes(p, os, FLAG_ITEM, outer, + context, "\\lang", + context.font.language, lang); + } else if (t.cs() == "inputencoding") { // nothing to write here -- 2.39.2