#include "Length.h"
#include "Preamble.h"
+#include "insets/ExternalTemplate.h"
+
#include "support/lassert.h"
#include "support/convert.h"
#include "support/FileName.h"
should be handled by this function:
- abc \j{} xyz
- abc \j {} xyz
- - abc \j
+ - abc \j
{} xyz
- abc \j %comment
{} xyz
while (optargs < context.layout->optargs) {
eat_whitespace(p, os, context, false);
if (p.next_token().cat() == catEscape ||
- p.next_token().character() != '[')
+ p.next_token().character() != '[')
break;
p.get_token(); // eat '['
begin_inset(os, "Argument\n");
// the inner env
if (!inner_type.empty() && (inner_flags & FLAG_END))
active_environments.pop_back();
-
+
// Ensure that the end of the outer box is parsed correctly:
// The opening brace has been eaten by parse_outer_box()
if (!outer_type.empty() && (outer_flags & FLAG_ITEM)) {
preamble.registerAutomaticallyLoadedPackage("verbatim");
}
+ else if (name == "verbatim") {
+ os << "\n\\begin_layout Verbatim\n";
+ string const s = p.verbatimEnvironment("verbatim");
+ string::const_iterator it2 = s.begin();
+ for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
+ if (*it == '\\')
+ os << "\\backslash ";
+ else if (*it == '\n') {
+ it2 = it + 1;
+ // avoid adding an empty paragraph at the end
+ // FIXME: if there are 2 consecutive spaces at the end ignore it
+ // because LyX will re-add a \n
+ // This hack must be removed once bug 8049 is fixed!
+ if ((it + 1 != et) && (it + 2 != et || *it2 != '\n'))
+ os << "\n\\end_layout\n\\begin_layout Verbatim\n";
+ } else
+ os << *it;
+ }
+ os << "\n\\end_layout\n\n";
+ p.skip_spaces();
+ // reset to Standard layout
+ os << "\n\\begin_layout Standard\n";
+ }
+
else if (name == "lyxgreyedout") {
eat_whitespace(p, os, parent_context, false);
parent_context.check_layout(os);
while (optargs < context.layout->optargs) {
eat_whitespace(p, os, context, false);
if (p.next_token().cat() == catEscape ||
- p.next_token().character() != '[')
+ p.next_token().character() != '[')
break;
p.get_token(); // eat '['
if (need_layout) {
handle_ert(os, command + ert, context);
}
+
+void registerExternalTemplatePackages(string const & name)
+{
+ external::TemplateManager const & etm = external::TemplateManager::get();
+ external::Template const * const et = etm.getTemplateByName(name);
+ if (!et)
+ return;
+ external::Template::Formats::const_iterator cit = et->formats.end();
+ if (pdflatex)
+ cit = et->formats.find("PDFLaTeX");
+ if (cit == et->formats.end())
+ // If the template has not specified a PDFLaTeX output,
+ // we try the LaTeX format.
+ cit = et->formats.find("LaTeX");
+ if (cit == et->formats.end())
+ return;
+ vector<string>::const_iterator qit = cit->second.requirements.begin();
+ vector<string>::const_iterator qend = cit->second.requirements.end();
+ for (; qit != qend; ++qit)
+ preamble.registerAutomaticallyLoadedPackage(*qit);
+}
+
} // anonymous namespace
// Store the latest bibliographystyle and nocite{*} option
// (needed for bibtex inset)
string btprint;
- string bibliographystyle;
+ string bibliographystyle = "default";
bool const use_natbib = preamble.isPackageUsed("natbib");
bool const use_jurabib = preamble.isPackageUsed("jurabib");
string last_env;
macro = false;
// register the packages that are automatically reloaded
// by the Gnumeric template
- // Fixme: InsetExternal.cpp should give us that list
- preamble.registerAutomaticallyLoadedPackage("array");
- preamble.registerAutomaticallyLoadedPackage("calc");
- preamble.registerAutomaticallyLoadedPackage("color");
- preamble.registerAutomaticallyLoadedPackage("hhline");
- preamble.registerAutomaticallyLoadedPackage("ifthen");
- preamble.registerAutomaticallyLoadedPackage("longtable");
- preamble.registerAutomaticallyLoadedPackage("multirow");
+ registerExternalTemplatePackages("GnumericSpreadsheet");
}
}
}
// Warn about invalid options.
// Check whether some option was given twice.
end_inset(os);
+ preamble.registerAutomaticallyLoadedPackage("graphicx");
}
else if (t.cs() == "footnote" ||
end_inset(os);
skip_spaces_braces(p);
}
-
+
else if (t.cs() == "lyxline") {
// swallow size argument (it is not used anyway)
p.getArg('{', '}');
btprint = key;
}
- else if (t.cs() == "index") {
+ else if (t.cs() == "index" ||
+ (t.cs() == "sindex" && preamble.use_indices() == "true")) {
context.check_layout(os);
- begin_inset(os, "Index idx\n");
- os << "status collapsed\n";
+ string const kind = (t.cs() == "index") ? "idx" : p.getArg('[', ']');
+ begin_inset(os, "Index ");
+ os << kind << "\nstatus collapsed\n";
parse_text_in_inset(p, os, FLAG_ITEM, false, context, "Index");
end_inset(os);
+ if (t.cs() == "sindex")
+ preamble.registerAutomaticallyLoadedPackage("splitidx");
}
else if (t.cs() == "nomenclature") {
end_inset(os);
preamble.registerAutomaticallyLoadedPackage("nomencl");
}
-
+
else if (t.cs() == "label") {
context.check_layout(os);
begin_command_inset(os, "label", "label");
else if (t.cs() == "selectlanguage") {
context.check_layout(os);
// save the language for the case that a
- // \foreignlanguage is used
+ // \foreignlanguage is used
context.font.language = babel2lyx(p.verbatim_item());
os << "\n\\lang " << context.font.language << "\n";
handle_ert(os, t.asInput(), context);
// accents (see Table 6 in Comprehensive LaTeX Symbol List)
- else if (t.cs().size() == 1
+ else if (t.cs().size() == 1
&& contains("\"'.=^`bcdHkrtuv~", t.cs())) {
context.check_layout(os);
// try to see whether the string is in unicodesymbols
docstring rem;
- string command = t.asInput() + "{"
+ string command = t.asInput() + "{"
+ trimSpaceAndEol(p.verbatim_item())
+ "}";
set<string> req;
Encodings::TEXT_CMD | Encodings::MATH_CMD, rem, &req);
if (!s.empty()) {
if (!rem.empty())
- cerr << "When parsing " << command
+ cerr << "When parsing " << command
<< ", result is " << to_utf8(s)
<< "+" << to_utf8(rem) << endl;
os << to_utf8(s);
begin_inset(os, "External\n");
os << "\ttemplate XFig\n"
<< "\tfilename " << outname << '\n';
+ registerExternalTemplatePackages("XFig");
} else {
begin_command_inset(os, "include", name);
os << "preview false\n"
os << "\tkeepAspectRatio\n";
end_inset(os);
context.check_layout(os);
+ registerExternalTemplatePackages("PDFPages");
}
else if (t.cs() == "loadgame") {
// after a \loadgame follows a \showboard
if (p.get_token().asInput() == "showboard")
p.get_token();
+ registerExternalTemplatePackages("ChessDiagram");
}
else {
Encodings::TEXT_CMD, rem, &req);
if (!s.empty()) {
if (!rem.empty())
- cerr << "When parsing " << t.cs()
+ cerr << "When parsing " << t.cs()
<< ", result is " << to_utf8(s)
<< "+" << to_utf8(rem) << endl;
context.check_layout(os);