]> git.lyx.org Git - features.git/blobdiff - src/tex2lyx/Preamble.cpp
Handle empty index subentries (#7820)
[features.git] / src / tex2lyx / Preamble.cpp
index e14176e87468c4ba2797f85551a5e07850961cbf..7b69bc4db5392eaa0bbba2853c42684f4866b721 100644 (file)
@@ -1950,6 +1950,11 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
           << "\\save_transient_properties " << h_save_transient_properties << "\n"
           << "\\origin " << origin << "\n"
           << "\\textclass " << h_textclass << "\n";
+       if (!h_doc_metadata.empty()) {
+               os << "\\begin_metadata\n"
+                  << h_doc_metadata
+                  << "\n\\end_metadata\n";
+       }
        string const raw = subdoc ? empty_string() : h_preamble.str();
        if (!raw.empty()) {
                os << "\\begin_preamble\n";
@@ -2169,17 +2174,17 @@ void Preamble::parse(Parser & p, string const & forceclass,
        if (detectEncoding && !is_full_document)
                return;
 
+       // Force textclass if the user wanted it
+       if (!forceclass.empty()) {
+               setTextClass(forceclass, tc);
+               class_set = true;
+       }
+
        while (is_full_document && p.good()) {
                if (detectEncoding && h_inputencoding != "auto-legacy" &&
                    h_inputencoding != "auto-legacy-plain")
                        return;
 
-               // Force textclass if the user wanted it
-               if (!forceclass.empty()) {
-                       setTextClass(forceclass, tc);
-                       class_set = true;
-               }
-
                Token const & t = p.get_token();
 
 #ifdef FILEDEBUG
@@ -2793,6 +2798,11 @@ void Preamble::parse(Parser & p, string const & forceclass,
                        continue;
                }
 
+               if (t.cs() == "DocumentMetadata") {
+                       h_doc_metadata = trimSpaceAndEol(p.getArg('{', '}'));
+                       continue;
+               }
+
                if (t.cs() == "usepackage") {
                        string const options = p.getArg('[', ']');
                        string const name = p.getArg('{', '}');