}
-string Parser::getFullOpt()
+string Parser::getFullOpt(bool keepws)
{
Arg arg = getFullArg('[', ']');
if (arg.first)
return '[' + arg.second + ']';
+ if (keepws)
+ unskip_spaces(true);
return string();
}
}
-string Parser::getOptContent()
-// the same as getOpt but without the brackets
-{
- string const res = getArg('[', ']');
- return res.empty() ? string() : res;
-}
-
-
string Parser::getFullParentheseArg()
{
Arg arg = getFullArg('(', ')');
*/
std::string getArg(char left, char right);
/*!
- * \returns getFullArg('[', ']') including the brackets or the
- * empty string if there is no such argument.
+ * Like getOpt(), but distinguishes between a missing argument ""
+ * and an empty argument "[]".
*/
- std::string getFullOpt();
+ std::string getFullOpt(bool keepws = false);
/*!
* \returns getArg('[', ']') including the brackets or the
* empty string if there is no such argument.
* during .tex export, thus creating an invalid command.
*/
std::string getOpt(bool keepws = false);
- /*!
- * the same as getOpt but without the brackets
- */
- std::string getOptContent();
/*!
* \returns getFullArg('(', ')') including the parentheses or the
* empty string if there is no such argument.
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
else if (t.cs() == "newenvironment") {
string const name = p.getArg('{', '}');
- string const opt1 = p.getOpt();
- string const opt2 = p.getOpt();
+ 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) {
break;
case optional:
// true because we must not eat whitespace
- ert += p.getOpt(true);
+ // if an optional arg follows me must not strip the
+ // brackets from this one
+ if (i < no_arguments - 1 &&
+ template_arguments[i+1] == optional)
+ ert += p.getFullOpt(true);
+ else
+ ert += p.getOpt(true);
break;
}
}
latex_width = "\\columnwidth";
else {
Parser p2(special);
- latex_width = p2.getOptContent();
- string const opt = p2.getOptContent();
+ latex_width = p2.getArg('[', ']');
+ string const opt = p2.getArg('[', ']');
if (!opt.empty()) {
hor_pos = opt;
if (hor_pos != "l" && hor_pos != "c" &&
context.set_item();
context.check_layout(os);
begin_command_inset(os, "bibitem", "bibitem");
- os << "label \"" << p.getOptContent() << "\"\n";
+ os << "label \"" << p.getArg('[', ']') << "\"\n";
os << "key \"" << p.verbatim_item() << "\"\n";
end_inset(os);
}
|| t.cs() == "nocite") {
context.check_layout(os);
// LyX cannot handle newlines in a latex command
- string after = subst(p.getOptContent(), "\n", " ");
+ string after = subst(p.getArg('[', ']'), "\n", " ");
string key = subst(p.verbatim_item(), "\n", " ");
// store the case that it is "\nocite{*}" to use it later for
// the BibTeX inset
context.check_layout(os);
begin_command_inset(os, "nomenclature", "nomenclature");
// LyX cannot handle newlines in a latex command
- string prefix = subst(p.getOptContent(), "\n", " ");
+ string prefix = subst(p.getArg('[', ']'), "\n", " ");
if (!prefix.empty())
os << "prefix " << '"' << prefix << '"' << "\n";
os << "symbol " << '"' << subst(p.verbatim_item(), "\n", " ") << '"' << "\n";
parse_outer_box(p, os, FLAG_ITEM, outer, context, t.cs(), "");
else if (t.cs() == "framebox") {
- string special = p.getOpt();
+ string special = p.getFullOpt();
special += p.getOpt();
parse_outer_box(p, os, FLAG_ITEM, outer, context, t.cs(), special);
}
name += '*';
}
string const command = p.verbatim_item();
- string const opt1 = p.getOpt();
+ string const opt1 = p.getFullOpt();
string const opt2 = p.getFullOpt();
add_known_command(command, opt1, !opt2.empty());
string const ert = name + '{' + command + '}' +