]> git.lyx.org Git - features.git/commitdiff
- tex2lyx/text.cpp:
authorUwe Stöhr <uwestoehr@lyx.org>
Fri, 22 Jun 2012 01:41:00 +0000 (03:41 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Fri, 22 Jun 2012 01:41:00 +0000 (03:41 +0200)
 - 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
src/tex2lyx/text.cpp

index 3ea7c1e53a9c56af9a2e60b93e2c1d905d6a6596..49d2e512c6193f0d4ccfadc541351840fb68a072 100644 (file)
 
 \part{df}
 
-1
+1 Coptic \textgreek{Greek} Coptic
 
 \begin{albanian}%
 
 \part{df}
 
-2
+2 Albanian \textgreek{Greek} Albanian
 
 \end{albanian}%
 \begin{divehi}%
 \part{df}
 
 5
+\end{divehi}%
+
+%empty language paragraph
+\begin{albanian}%
+\end{albanian}%
+
 \end{document}
index 55e964c7f5368e5c27104f6971c660b23ae6a97b..92934cce94bdc3cdc879633697de16fda0885713 100644 (file)
@@ -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