extern map<char, int> special_columns;
map<string, vector<string> > used_packages;
+const char * const modules_placeholder = "\001modules\001";
// needed to handle encodings with babel
bool one_language = true;
string h_cite_engine = "basic";
string h_use_bibtopic = "false";
string h_paperorientation = "portrait";
+string h_notefontcolor;
string h_secnumdepth = "3";
string h_tocdepth = "3";
string h_paragraph_separation = "indent";
if (!h_options.empty())
os << "\\options " << h_options << "\n";
os << "\\use_default_options " << h_use_default_options << "\n"
+ << modules_placeholder
<< "\\language " << h_language << "\n"
<< "\\inputencoding " << h_inputencoding << "\n"
<< "\\font_roman " << h_font_roman << "\n"
<< "\\use_esint " << h_use_esint << "\n"
<< "\\cite_engine " << h_cite_engine << "\n"
<< "\\use_bibtopic " << h_use_bibtopic << "\n"
- << "\\paperorientation " << h_paperorientation << "\n"
- << h_margins
+ << "\\paperorientation " << h_paperorientation << '\n';
+ if (LYX_FORMAT >= 382 && !h_notefontcolor.empty())
+ os << "\\notefontcolor " << h_notefontcolor << '\n';
+ os << h_margins
<< "\\secnumdepth " << h_secnumdepth << "\n"
<< "\\tocdepth " << h_tocdepth << "\n"
<< "\\paragraph_separation " << h_paragraph_separation << "\n";
h_preamble << t.asInput();
else if (t.cat() == catComment) {
- // regex to parse comments (currently not used)
static regex const islyxfile("%% LyX .* created this file");
static regex const usercommands("User specified LaTeX commands");
p.setCatCode('@', catOther);
}
- else if (t.cs() == "newcommand" || t.cs() == "renewcommand"
- || t.cs() == "providecommand"
+ else if (t.cs() == "newcommand" || t.cs() == "newcommandx"
+ || t.cs() == "renewcommand" || t.cs() == "renewcommandx"
+ || t.cs() == "providecommand" || t.cs() == "providecommandx"
|| t.cs() == "DeclareRobustCommand"
+ || t.cs() == "DeclareRobustCommandx"
|| t.cs() == "ProvideTextCommandDefault"
|| t.cs() == "DeclareMathAccent") {
bool star = false;
star = true;
}
string const name = p.verbatim_item();
- string const opt1 = p.getOpt();
+ string const opt1 = p.getFullOpt();
string const opt2 = p.getFullOpt();
string const body = p.verbatim_item();
// font settings
// remove leading "\"
h_font_default_family = family.erase(0,1);
}
+
+ // Add the command to the known commands
+ add_known_command(name, opt1, !opt2.empty(), from_utf8(body));
+
// only non-lyxspecific stuff
if (!in_lyx_preamble) {
ostringstream ss;
ss << '{' << name << '}' << opt1 << opt2
<< '{' << body << "}";
h_preamble << ss.str();
-
- // Add the command to the known commands
- add_known_command(name, opt1, !opt2.empty());
/*
ostream & out = in_preamble ? h_preamble : os;
out << "\\" << t.cs() << "{" << name << "}"
// options.
handle_opt(opts, known_languages, h_language);
delete_opt(opts, known_languages);
-
+
// paper orientation
if ((it = find(opts.begin(), opts.end(), "landscape")) != opts.end()) {
h_paperorientation = "landscape";
delete_opt(opts, known_class_paper_sizes);
// the remaining options
h_options = join(opts, ",");
+ // FIXME This does not work for classes that have a
+ // different name in LyX than in LaTeX
h_textclass = p.getArg('{', '}');
}
else if (t.cs() == "newenvironment") {
string const name = p.getArg('{', '}');
- ostringstream ss;
- ss << "\\newenvironment{" << name << "}";
- ss << p.getOpt();
- ss << p.getOpt();
- ss << '{' << p.verbatim_item() << '}';
- ss << '{' << p.verbatim_item() << '}';
- if (!in_lyx_preamble)
- h_preamble << ss.str();
+ string const opt1 = p.getFullOpt();
+ string const opt2 = p.getFullOpt();
+ string const beg = p.verbatim_item();
+ string const end = p.verbatim_item();
+ if (!in_lyx_preamble) {
+ h_preamble << "\\newenvironment{" << name
+ << '}' << opt1 << opt2 << '{'
+ << beg << "}{" << end << '}';
+ }
+ add_known_environment(name, opt1, !opt2.empty(),
+ from_utf8(beg), from_utf8(end));
+
}
else if (t.cs() == "def") {
}
}
+ else if (t.cs() == "definecolor") {
+ string const color = p.getArg('{', '}');
+ string const space = p.getArg('{', '}');
+ string const value = p.getArg('{', '}');
+ if (LYX_FORMAT >= 382 &&
+ color == "note_fontcolor" && space == "rgb") {
+ RGBColor c(RGBColorFromLaTeX(value));
+ h_notefontcolor = X11hexname(c);
+ } else {
+ h_preamble << "\\definecolor{" << color
+ << "}{" << space << "}{" << value
+ << '}';
+ }
+ }
+
else if (t.cs() == "jurabibsetup") {
// FIXME p.getArg('{', '}') is most probably wrong (it
// does not handle nested braces).
h_textclass = forceclass;
if (noweb_mode && !prefixIs(h_textclass, "literate-"))
h_textclass.insert(0, "literate-");
- FileName layoutfilename = libFileSearch("layouts", h_textclass, "layout");
- if (layoutfilename.empty()) {
- cerr << "Error: Could not find layout file for textclass \"" << h_textclass << "\"." << endl;
- exit(1);
+ tc.setName(h_textclass);
+ if (!tc.load()) {
+ cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
+ exit(EXIT_FAILURE);
}
- tc.read(layoutfilename);
if (h_papersides.empty()) {
ostringstream ss;
ss << tc.sides();