namespace {
-// "chinese-simplified", "chinese-traditional", "japanese-cjk", "korean"
-// cannot be supported because it is impossible to determine the correct document
-// language if CJK is used.
+// CJK languages are handled in text.cpp, polyglossia languages are listed
+// further down.
/**
* known babel language names (including synonyms)
* not in standard babel: arabic, arabtex, armenian, belarusian, serbian-latin, thai
"uppersorbian", "uppersorbian", "english", "english", "vietnamese", "welsh",
0};
-/**
- * known polyglossia language names (including variants)
- */
-const char * const polyglossia_languages[] = {
-"albanian", "croatian", "hebrew", "norsk", "swedish", "amharic", "czech", "hindi",
-"nynorsk", "syriac", "arabic", "danish", "icelandic", "occitan", "tamil",
-"armenian", "divehi", "interlingua", "polish", "telugu", "asturian", "dutch",
-"irish", "portuges", "thai", "bahasai", "english", "italian", "romanian", "turkish",
-"bahasam", "esperanto", "lao", "russian", "turkmen", "basque", "estonian", "latin",
-"samin", "ukrainian", "bengali", "farsi", "latvian", "sanskrit", "urdu", "brazil",
-"brazilian", "finnish", "lithuanian", "scottish", "usorbian", "breton", "french",
-"lsorbian", "serbian", "vietnamese", "bulgarian", "galician", "magyar", "slovak",
-"welsh", "catalan", "german", "malayalam", "slovenian", "coptic", "greek",
-"marathi", "spanish",
-"american", "ancient", "australian", "british", "monotonic", "newzealand",
-"polytonic", 0};
-
-/**
- * the same as polyglossia_languages with .lyx names
- * please keep this in sync with polyglossia_languages line by line!
- */
-const char * const coded_polyglossia_languages[] = {
-"albanian", "croatian", "hebrew", "norsk", "swedish", "amharic", "czech", "hindi",
-"nynorsk", "syriac", "arabic_arabi", "danish", "icelandic", "occitan", "tamil",
-"armenian", "divehi", "interlingua", "polish", "telugu", "asturian", "dutch",
-"irish", "portuges", "thai", "bahasa", "english", "italian", "romanian", "turkish",
-"bahasam", "esperanto", "lao", "russian", "turkmen", "basque", "estonian", "latin",
-"samin", "ukrainian", "bengali", "farsi", "latvian", "sanskrit", "urdu", "brazilian",
-"brazilian", "finnish", "lithuanian", "scottish", "uppersorbian", "breton", "french",
-"lowersorbian", "serbian", "vietnamese", "bulgarian", "galician", "magyar", "slovak",
-"welsh", "catalan", "ngerman", "malayalam", "slovene", "coptic", "greek",
-"marathi", "spanish",
-"american", "ancientgreek", "australian", "british", "greek", "newzealand",
-"polutonikogreek", 0};
+/// languages with danish quotes (.lyx names)
+const char * const known_danish_quotes_languages[] = {"danish", 0};
/// languages with english quotes (.lyx names)
const char * const known_english_quotes_languages[] = {"american", "australian",
} // anonymous namespace
+/**
+ * known polyglossia language names (including variants)
+ */
+const char * const Preamble::polyglossia_languages[] = {
+"albanian", "croatian", "hebrew", "norsk", "swedish", "amharic", "czech", "hindi",
+"nynorsk", "syriac", "arabic", "danish", "icelandic", "occitan", "tamil",
+"armenian", "divehi", "interlingua", "polish", "telugu", "asturian", "dutch",
+"irish", "portuges", "thai", "bahasai", "english", "italian", "romanian", "turkish",
+"bahasam", "esperanto", "lao", "russian", "turkmen", "basque", "estonian", "latin",
+"samin", "ukrainian", "bengali", "farsi", "latvian", "sanskrit", "urdu", "brazil",
+"brazilian", "finnish", "lithuanian", "scottish", "usorbian", "breton", "french",
+"lsorbian", "serbian", "vietnamese", "bulgarian", "galician", "magyar", "slovak",
+"welsh", "catalan", "german", "malayalam", "slovenian", "coptic", "greek",
+"marathi", "spanish",
+"american", "ancient", "australian", "british", "monotonic", "newzealand",
+"polytonic", 0};
+
+/**
+ * the same as polyglossia_languages with .lyx names
+ * please keep this in sync with polyglossia_languages line by line!
+ */
+const char * const Preamble::coded_polyglossia_languages[] = {
+"albanian", "croatian", "hebrew", "norsk", "swedish", "amharic", "czech", "hindi",
+"nynorsk", "syriac", "arabic_arabi", "danish", "icelandic", "occitan", "tamil",
+"armenian", "divehi", "interlingua", "polish", "telugu", "asturian", "dutch",
+"irish", "portuges", "thai", "bahasa", "english", "italian", "romanian", "turkish",
+"bahasam", "esperanto", "lao", "russian", "turkmen", "basque", "estonian", "latin",
+"samin", "ukrainian", "bengali", "farsi", "latvian", "sanskrit", "urdu", "brazilian",
+"brazilian", "finnish", "lithuanian", "scottish", "uppersorbian", "breton", "french",
+"lowersorbian", "serbian", "vietnamese", "bulgarian", "galician", "magyar", "slovak",
+"welsh", "catalan", "ngerman", "malayalam", "slovene", "coptic", "greek",
+"marathi", "spanish",
+"american", "ancientgreek", "australian", "british", "greek", "newzealand",
+"polutonikogreek", 0};
+
+
bool Preamble::indentParagraphs() const
{
return h_paragraph_separation == "indent";
h_font_roman = "default";
h_font_sans = "default";
h_font_typewriter = "default";
+ h_font_math = "auto";
h_font_default_family = "default";
h_use_non_tex_fonts = "false";
h_font_sc = "false";
h_use_indices = "false";
h_use_geometry = "false";
h_use_default_options = "false";
- h_use_hyperref = "0";
- h_use_refstyle = "1";
+ h_use_hyperref = "false";
+ h_use_refstyle = "0";
h_use_packages["amsmath"] = "1";
- h_use_packages["amssymb"] = "1";
+ h_use_packages["amssymb"] = "0";
h_use_packages["esint"] = "1";
- h_use_packages["mhchem"] = "1";
- h_use_packages["mathdots"] = "1";
- h_use_packages["mathtools"] = "1";
- h_use_packages["undertilde"] = "1";
+ h_use_packages["mhchem"] = "0";
+ h_use_packages["mathdots"] = "0";
+ h_use_packages["mathtools"] = "0";
+ h_use_packages["undertilde"] = "0";
}
{
// FIXME swallow inputencoding changes that might surround the
// hyperref setup if it was written by LyX
- h_use_hyperref = "1";
+ h_use_hyperref = "true";
// swallow "unicode=true", since LyX does always write that
vector<string>::iterator it =
find(options.begin(), options.end(), "unicode=true");
vector<string> options = split_options(opts);
add_package(name, options);
string scale;
+ char const * const * where = 0;
if (is_known(name, known_xetex_packages)) {
xetex = true;
}
// roman fonts
- if (is_known(name, known_roman_fonts)) {
+ if (is_known(name, known_roman_fonts))
h_font_roman = name;
- p.skip_spaces();
- }
if (name == "fourier") {
h_font_roman = "utopia";
}
else if (name == "CJK") {
- // It is impossible to determine the document language if CJK is used.
- // All we can do is to notify the user that he has to set this by himself.
- have_CJK = true;
// set the encoding to "auto" because it might be set to "default" by the babel handling
// and this would not be correct for CJK
- h_inputencoding = "auto";
+ if (h_inputencoding == "default")
+ h_inputencoding = "auto";
registerAutomaticallyLoadedPackage("CJK");
}
else if (is_known(name, known_lyx_packages) && options.empty()) {
if (name == "splitidx")
h_use_indices = "true";
- if (!in_lyx_preamble)
+ if (!in_lyx_preamble) {
h_preamble << package_beg_sep << name
<< package_mid_sep << "\\usepackage{"
- << name << "}\n" << package_end_sep;
+ << name << '}';
+ if (p.next_token().cat() == catNewline ||
+ (p.next_token().cat() == catSpace &&
+ p.next_next_token().cat() == catNewline))
+ h_preamble << '\n';
+ h_preamble << package_end_sep;
+ }
}
else if (name == "geometry")
else if (name == "subfig")
; // ignore this FIXME: Use the package separator mechanism instead
- else if (is_known(name, known_languages))
- h_language = name;
+ else if ((where = is_known(name, known_languages)))
+ h_language = known_coded_languages[where - known_languages];
else if (name == "natbib") {
h_biblio_style = "plainnat";
else if (!in_lyx_preamble) {
if (options.empty())
- h_preamble << "\\usepackage{" << name << "}\n";
+ h_preamble << "\\usepackage{" << name << '}';
else {
h_preamble << "\\usepackage[" << opts << "]{"
- << name << "}\n";
+ << name << '}';
options.clear();
}
+ if (p.next_token().cat() == catNewline ||
+ (p.next_token().cat() == catSpace &&
+ p.next_next_token().cat() == catNewline))
+ h_preamble << '\n';
}
// We need to do something with the options...
// http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
// (quotes for kazakh and interlingua are unknown)
// danish
- if (h_language == "danish")
+ if (is_known(h_language, known_danish_quotes_languages))
h_quotes_language = "danish";
// french
else if (is_known(h_language, known_french_quotes_languages))
<< "\\font_roman " << h_font_roman << "\n"
<< "\\font_sans " << h_font_sans << "\n"
<< "\\font_typewriter " << h_font_typewriter << "\n"
+ << "\\font_math " << h_font_math << "\n"
<< "\\font_default_family " << h_font_default_family << "\n"
<< "\\use_non_tex_fonts " << h_use_non_tex_fonts << "\n"
<< "\\font_sc " << h_font_sc << "\n"
os << "\\paperfontsize " << h_paperfontsize << "\n"
<< "\\spacing " << h_spacing << "\n"
<< "\\use_hyperref " << h_use_hyperref << '\n';
- if (h_use_hyperref == "1") {
+ if (h_use_hyperref == "true") {
if (!h_pdf_title.empty())
os << "\\pdf_title \"" << h_pdf_title << "\"\n";
if (!h_pdf_author.empty())
// check if the option contains a scaling, if yes, extract it
string::size_type pos = fontopts.find("Scale");
if (pos != string::npos) {
- string::size_type i = fontopts.find(',');
+ string::size_type i = fontopts.find(',', pos);
if (i == string::npos)
scale = scale_as_percentage(fontopts.substr(pos + 1));
else
ss << tc.sides();
h_papersides = ss.str();
}
+
+ // If the CJK package is used we cannot set the document language from
+ // the babel options. Instead, we guess which language is used most
+ // and set this one.
+ default_language = h_language;
+ if (is_full_document && auto_packages.find("CJK") != auto_packages.end()) {
+ p.pushPosition();
+ h_language = guessLanguage(p, default_language);
+ p.popPosition();
+ }
}
}
-string polyglossia2lyx(string const & language)
+string Preamble::polyglossia2lyx(string const & language)
{
char const * const * where = is_known(language, polyglossia_languages);
if (where)