]> git.lyx.org Git - features.git/commitdiff
Prevent multiplication of preamble code
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 4 Apr 2019 14:39:20 +0000 (16:39 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 19 Jun 2019 15:13:16 +0000 (17:13 +0200)
Fixes rest of #8229

(cherry picked from commit f51fa38123fb7e3daf37ebfd3e7b0a9feb23b7a1)

src/tex2lyx/Preamble.cpp
status.23x

index 436c961545ce3635c6a39d29972fc8dc1fab448c..9d2c4c1bde2dc2cf89bd907bff9df20c1d136397 100644 (file)
@@ -944,11 +944,14 @@ void Preamble::handle_package(Parser &p, string const & name,
                                // perhaps in future others.
                                // Therefore keep the babel call as it is as the user might have
                                // reasons for it.
-                               h_preamble << "\\usepackage[" << opts << "]{babel}\n";
+                               string const babelcall = "\\usepackage[" + opts + "]{babel}\n";
+                               if (!contains(h_preamble.str(), babelcall))
+                                       h_preamble << babelcall;
                        }
                        delete_opt(options, known_languages);
                } else {
-                       h_preamble << "\\usepackage{babel}\n";
+                       if (!contains(h_preamble.str(), "\\usepackage{babel}\n"))
+                               h_preamble << "\\usepackage{babel}\n";
                        explicit_babel = true;
                }
        }
@@ -1781,7 +1784,8 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                        ss << '*';
                                ss << '{' << name << '}' << opt1 << opt2
                                   << '{' << body << "}";
-                               h_preamble << ss.str();
+                               if (prefixIs(t.cs(), "renew") || !contains(h_preamble.str(), ss.str()))
+                                       h_preamble << ss.str();
 /*
                                ostream & out = in_preamble ? h_preamble : os;
                                out << "\\" << t.cs() << "{" << name << "}"
index 9b0ff657f2d8f3ab8251ee04a6b68194fbcb912a..2791d670db6d659050351ca38e48b31485af0759 100644 (file)
@@ -73,7 +73,7 @@ What's new
 
 * TEX2LYX
 
-
+- Prevent multiplication of preamble code on (re-)import (bug 8229).
 
 
 * LYXHTML