mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
tex2lyx/preamble.cpp: improve the fix from r31440:
- when languages are given in the documentclass options _and_ the babel options, babel takes the last language option of the \usepackage call - there is no quote language "ngerman", it is in both cases "german" git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31685 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d98251c379
commit
d319b368c7
@ -49,9 +49,6 @@ map<string, vector<string> > used_packages;
|
||||
// needed to handle encodings with babel
|
||||
bool one_language = true;
|
||||
|
||||
// to avoid that the babel options overwrite the documentclass options
|
||||
bool documentclass_language = false;
|
||||
|
||||
namespace {
|
||||
|
||||
const char * const known_languages[] = { "afrikaans", "american", "arabic",
|
||||
@ -140,7 +137,6 @@ string h_tracking_changes = "false";
|
||||
string h_output_changes = "false";
|
||||
string h_margins = "";
|
||||
|
||||
|
||||
// returns true if at least one of the options in what has been found
|
||||
bool handle_opt(vector<string> & opts, char const * const * what, string & target)
|
||||
{
|
||||
@ -315,30 +311,29 @@ void handle_package(Parser &p, string const & name, string const & opts,
|
||||
one_language = false;
|
||||
h_inputencoding = "auto";
|
||||
}
|
||||
// only set the document language when there was not already one set
|
||||
// via the documentclass options
|
||||
// babel takes the the last language given in the documentclass options
|
||||
// as document language. If there is no such language option, the last
|
||||
// option of its \usepackage call is used.
|
||||
if (documentclass_language == false) {
|
||||
handle_opt(options, known_languages, h_language);
|
||||
delete_opt(options, known_languages);
|
||||
if (is_known(h_language, known_brazilian_languages))
|
||||
h_language = "brazilian";
|
||||
else if (is_known(h_language, known_french_languages))
|
||||
h_language = "french";
|
||||
else if (is_known(h_language, known_german_languages))
|
||||
h_language = "german";
|
||||
else if (is_known(h_language, known_ngerman_languages))
|
||||
h_language = "ngerman";
|
||||
else if (is_known(h_language, known_portuguese_languages))
|
||||
h_language = "portuguese";
|
||||
else if (is_known(h_language, known_russian_languages))
|
||||
h_language = "russian";
|
||||
else if (is_known(h_language, known_ukrainian_languages))
|
||||
h_language = "ukrainian";
|
||||
h_quotes_language = h_language;
|
||||
}
|
||||
// babel takes the the last language of the option of its \usepackage
|
||||
// call as document language. If there is no such language option, the
|
||||
// last language in the documentclass options is used.
|
||||
handle_opt(options, known_languages, h_language);
|
||||
delete_opt(options, known_languages);
|
||||
if (is_known(h_language, known_brazilian_languages))
|
||||
h_language = "brazilian";
|
||||
else if (is_known(h_language, known_french_languages))
|
||||
h_language = "french";
|
||||
else if (is_known(h_language, known_german_languages))
|
||||
h_language = "german";
|
||||
else if (is_known(h_language, known_ngerman_languages))
|
||||
h_language = "ngerman";
|
||||
else if (is_known(h_language, known_portuguese_languages))
|
||||
h_language = "portuguese";
|
||||
else if (is_known(h_language, known_russian_languages))
|
||||
h_language = "russian";
|
||||
else if (is_known(h_language, known_ukrainian_languages))
|
||||
h_language = "ukrainian";
|
||||
h_quotes_language = h_language;
|
||||
// there is only the quotes language "german"
|
||||
if (h_quotes_language == "ngerman")
|
||||
h_quotes_language = "german";
|
||||
}
|
||||
|
||||
else if (name == "fontenc")
|
||||
@ -417,6 +412,9 @@ void handle_package(Parser &p, string const & name, string const & opts,
|
||||
else
|
||||
h_language = name;
|
||||
h_quotes_language = h_language;
|
||||
// there is only the quotes language "german"
|
||||
if (h_quotes_language == "ngerman")
|
||||
h_quotes_language = "german";
|
||||
}
|
||||
|
||||
else if (name == "natbib") {
|
||||
@ -653,9 +651,10 @@ void parse_preamble(Parser & p, ostream & os,
|
||||
string::size_type i = h_paperfontsize.find("pt");
|
||||
if (i != string::npos)
|
||||
h_paperfontsize.erase(i);
|
||||
// to avoid that the babel options overwrite the documentclass options
|
||||
documentclass_language =
|
||||
handle_opt(opts, known_languages, h_language);
|
||||
// The documentclass options are always parsed before the options
|
||||
// of the babel call so that a language cannot overwrite the babel
|
||||
// options.
|
||||
handle_opt(opts, known_languages, h_language);
|
||||
delete_opt(opts, known_languages);
|
||||
if (is_known(h_language, known_brazilian_languages))
|
||||
h_language = "brazilian";
|
||||
|
Loading…
Reference in New Issue
Block a user