]> git.lyx.org Git - lyx.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>
Thu, 4 Apr 2019 14:39:20 +0000 (16:39 +0200)
Fixes rest of #8229

src/tex2lyx/Preamble.cpp

index 39298851d153dd68d86bd241e2f0940d1f2281c6..3114552afcbc35a9118dee3135ac37876db8bd10 100644 (file)
@@ -1053,11 +1053,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;
                }
        }
@@ -1909,7 +1912,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 << "}"