Fix regression of 18779013 for \smash

When adding native support for \smash in 18779013 I overlooked that amsmath
redefines \smash to take an optional argument t or b. These optional
arguments are not parsed correctly anymore (bug 8967). This change fixes
the regression, so that \smash with optional argument appears in red, as it
was before th introduction of the native smash inset.
In the future, we should have native support for \smash[t] and \smash[b]
as well, but this would be a file format change (automatic amsmath loading),
and it is too late for 2.1.0.
This commit is contained in:
Georg Baum 2014-02-19 20:50:57 +01:00
parent cfe9724a4c
commit 227675ee02

View File

@ -1831,6 +1831,27 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
}
}
else if (t.cs() == "smash") {
skipSpaces();
if (nextToken().asInput() == "[") {
// Since the phantom inset cannot handle optional arguments
// we must not create an InsetMathPhantom (bug 8967).
docstring const opt = parse_verbatim_option();
docstring const arg = parse_verbatim_item();
cell->push_back(MathAtom(new MathMacro(buf, t.cs())));
MathData ar;
mathed_parse_cell(ar, '[' + opt + ']', mode_);
cell->append(ar);
ar = MathData();
mathed_parse_cell(ar, '{' + arg + '}', mode_);
cell->append(ar);
}
else {
cell->push_back(createInsetMath(t.cs(), buf));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
}
#if 0
else if (t.cs() == "infer") {
MathData ar;