Prevent multiplication of preamble code

Fixes rest of #8229

(cherry picked from commit f51fa38123)
This commit is contained in:
Juergen Spitzmueller 2019-04-04 16:39:20 +02:00
parent f8eb3b9742
commit 019a4fa124
2 changed files with 8 additions and 4 deletions

View 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 << "}"

View File

@ -73,7 +73,7 @@ What's new
* TEX2LYX
- Prevent multiplication of preamble code on (re-)import (bug 8229).
* LYXHTML