From 227675ee022c4c5f031038dd804738e716aefa55 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Wed, 19 Feb 2014 20:50:57 +0100 Subject: [PATCH] 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. --- src/mathed/MathParser.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index ef987789b3..317e7b0a73 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -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;