#include "Encoding.h"
#include "LayoutFile.h"
-#include "Layout.h"
#include "Lexer.h"
#include "TextClass.h"
#include "version.h"
#include "support/filetools.h"
#include "support/lstrings.h"
-#include "support/regex.h"
-
#include <algorithm>
#include <iostream>
+#include <regex>
using namespace std;
using namespace lyx::support;
const char * const known_polish_quotes_languages[] = {"afrikaans", "bosnian", "croatian",
"dutch", "magyar", "polish", "romanian", "serbian", "serbian-latin", 0};
+/// languages with hungarian quotes (.lyx names)
+const char * const known_hungarian_quotes_languages[] = {"magyar", 0};
+
/// languages with russian quotes (.lyx names)
const char * const known_russian_quotes_languages[] = {"azerbaijani", "oldrussian",
"russian", "ukrainian", 0};
* \p options and return the value.
* The found option is also removed from \p options.
*/
-string process_keyval_opt(vector<string> & options, string name)
+string process_keyval_opt(vector<string> & options, string const & name)
{
for (size_t i = 0; i < options.size(); ++i) {
vector<string> option;
void Preamble::add_package(string const & name, vector<string> & options)
{
// every package inherits the global options
- if (used_packages.find(name) == used_packages.end())
- used_packages[name] = split_options(h_options);
+ used_packages.insert({name, split_options(h_options)});
// Insert options passed via PassOptionsToPackage
for (auto const & p : extra_package_options_) {
}
}
+void Preamble::setTextClass(string const & tclass, TeX2LyXDocClass & tc)
+{
+ h_textclass = tclass;
+ tc.setName(h_textclass);
+ if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
+ cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
+ exit(EXIT_FAILURE);
+ }
+}
+
namespace {
bool is_full_document = false;
bool is_lyx_file = false;
bool in_lyx_preamble = false;
+ bool class_set = false;
// determine whether this is a full document or a fragment for inclusion
while (p.good()) {
h_inputencoding != "auto-legacy-plain")
return;
+ // Force textclass if the user wanted it
+ if (!forceclass.empty()) {
+ setTextClass(forceclass, tc);
+ class_set = true;
+ }
+
Token const & t = p.get_token();
#ifdef FILEDEBUG
vector<string> opts = split_options(p.getArg('[', ']'));
// FIXME This does not work for classes that have a
// different name in LyX than in LaTeX
- h_textclass = p.getArg('{', '}');
+ string const tclass = p.getArg('{', '}');
p.skip_spaces();
- // Force textclass if the user wanted it
- if (!forceclass.empty())
- h_textclass = forceclass;
- tc.setName(h_textclass);
- if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
- cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
- exit(EXIT_FAILURE);
+ // Only set text class if a class hasn't been forced
+ // (this was set above)
+ if (!class_set) {
+ // textclass needs to be set at this place (if not already done)
+ // as we need to know it for other parameters
+ // (such as class-dependent paper size)
+ setTextClass(tclass, tc);
+ class_set = true;
}
// Font sizes.
// paper sizes
// some size options are known by the document class, other sizes
// are handled by the \geometry command of the geometry package
- string paper;
vector<string> class_psizes = getVectorFromString(tc.opt_pagesize(), "|");
string const psize_format = tc.pagesizeformat();
for (auto const & psize : class_psizes) {
}
}
+ // set textclass if not yet done (snippets without \documentclass and forced class)
+ if (!class_set)
+ setTextClass(h_textclass, tc);
+
// remove the whitespace
p.skip_spaces();
// polish
else if (is_known(h_language, known_polish_quotes_languages))
h_quotes_style = "polish";
+ // hungarian
+ else if (is_known(h_language, known_hungarian_quotes_languages))
+ h_quotes_style = "hungarian";
// russian
else if (is_known(h_language, known_russian_quotes_languages))
h_quotes_style = "russian";