]> git.lyx.org Git - features.git/commitdiff
be kind to XaFooBarTeX
authorAndré Pönitz <poenitz@gmx.net>
Sun, 12 Oct 2008 19:19:41 +0000 (19:19 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 12 Oct 2008 19:19:41 +0000 (19:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26871 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/preamble.cpp

index 62dd2abb491dee139071574ec1488661d72227bb..a87d784dbf62a07461b4ecade8db0de47834adaa 100644 (file)
@@ -512,7 +512,18 @@ void parse_preamble(Parser & p, ostream & os,
                        static regex const usercommands("User specified LaTeX commands");
                        
                        string const comment = t.asInput();
-                       cerr << "Seen comment: " << comment << std::endl;
+                       //cerr << "Seen comment: " << comment << std::endl;
+                       
+                       // magically switch encoding default if it looks like XeLaTeX
+                       static string const magicXeLaTeX =
+                               "% This document must be compiled with XeLaTeX ";
+                       if (comment.size() > magicXeLaTeX.size() 
+                                 && comment.substr(0, magicXeLaTeX.size()) == magicXeLaTeX
+                                 && h_inputencoding == "auto") {
+                               cerr << "XeLaTeX comment found, switching to UTF8\n";
+                               h_inputencoding = "utf8";
+                       }
+
                        smatch sub;
                        if (regex_search(comment, sub, islyxfile))
                                is_lyx_file = true;