]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/Preamble.cpp
Fix "stray '}' in text" warnings: When parsing with FLAG_ITEM the braces need
[lyx.git] / src / tex2lyx / Preamble.cpp
index dace26f0e3b88ff6e65f8332097967c646b6dccb..c0b3cb9ac4cc9e81d54b889f10a42c6a6ec3cb14 100644 (file)
@@ -165,6 +165,11 @@ const char * const known_basic_color_codes[] = {"#0000ff", "#000000", "#00ffff",
 const char * const known_if_3arg_commands[] = {"@ifundefined", "IfFileExists",
 0};
 
+/// packages that work only in xetex
+const char * const known_xetex_packages[] = {"arabxetex", "fixlatvian",
+"fontbook", "fontwrap", "mathspec", "philokalia", "polyglossia", "unisugar",
+"xeCJK", "xecolor", "xecyr", "xeindex", "xepersian", "xunicode", 0};
+
 // codes used to remove packages that are loaded automatically by LyX.
 // Syntax: package_beg_sep<name>package_mid_sep<package loading code>package_end_sep
 const char package_beg_sep = '\001';
@@ -313,6 +318,28 @@ void Preamble::suppressDate(bool suppress)
 }
 
 
+void Preamble::registerAuthor(std::string const & name)
+{
+       Author author(from_utf8(name), empty_docstring());
+       author.setUsed(true);
+       authors_.record(author);
+       h_tracking_changes = "true";
+       h_output_changes = "true";
+}
+
+
+Author const & Preamble::getAuthor(std::string const & name) const
+{
+       Author author(from_utf8(name), empty_docstring());
+       for (AuthorList::Authors::const_iterator it = authors_.begin();
+            it != authors_.end(); it++)
+               if (*it == author)
+                       return *it;
+       static Author const dummy;
+       return dummy;
+}
+
+
 void Preamble::add_package(string const & name, vector<string> & options)
 {
        // every package inherits the global options
@@ -524,6 +551,9 @@ void Preamble::handle_package(Parser &p, string const & name,
        add_package(name, options);
        string scale;
 
+       if (is_known(name, known_xetex_packages))
+               xetex = true;
+
        // roman fonts
        if (is_known(name, known_roman_fonts)) {
                h_font_roman = name;
@@ -910,6 +940,7 @@ bool Preamble::writeLyXHeader(ostream & os)
           << "\\html_math_output " << h_html_math_output << "\n"
           << "\\html_css_as_file " << h_html_css_as_file << "\n"
           << "\\html_be_strict " << h_html_be_strict << "\n"
+          << authors_
           << "\\end_header\n\n"
           << "\\begin_body\n";
        // clear preamble for subdocuments
@@ -1004,7 +1035,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
 
                else if (t.cs() == "color") {
                        string const space =
-                               (p.hasOpt() ? p.getArg('[', ']') : string());
+                               (p.hasOpt() ? p.getOpt() : string());
                        string argument = p.getArg('{', '}');
                        // check the case that a standard color is used
                        if (space.empty() && is_known(argument, known_basic_colors)) {
@@ -1017,7 +1048,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
                        else {
                                h_preamble << t.asInput();
                                if (!space.empty())
-                                       h_preamble << '[' << space << ']';
+                                       h_preamble << space;
                                h_preamble << '{' << argument << '}';
                                // the color might already be set because \definecolor
                                // is parsed before this