parse(ar, FLAG_BRACE_LAST, mode);
// do not create a BraceInset if they were written by LyX
// this helps to keep the annoyance of "a choose b" to a minimum
- InsetMathMacro const * ma;
- InsetMathBrace const * mb;
- InsetMathChar const * mc;
- for (size_type i = 0; i < ar.size(); ++i) {
- mb = ar[i]->asBraceInset();
- ma = mb && mb->cell(0).size()
- ? mb->cell(0)[0]->asMacro() : 0;
- mc = ma && mb && mb->cell(0).size() > 1
- ? mb->cell(0)[1]->asCharInset(): 0;
- bool has_opts = mc && mc->getChar() == '[';
- // If this is a macro, it may have optional
- // arguments, even if only defaults are used.
- // In this case, there is no following '['.
- if (!has_opts && ma && buf) {
- if (mode_ & Parse::TRACKMACRO)
- has_opts = buf->usermacros_with_opts.count(ma->name());
- else {
- MacroData const * md = buf->getMacro(ma->name(), false);
- has_opts = md && md->optionals();
- }
- }
- if (has_opts) {
- // Remove the BraceInset around a macro
- // with optional arguments. It will be
- // automatically reinserted on write.
- MathData md = mb->cell(0);
- ar.erase(i);
- ar.insert(i,md);
- }
- }
if (ar.size() == 1 && ar[0]->extraBraces())
cell->append(ar);
else
name, nargs, optionals, MacroTypeNewcommand,
optionalValues, def, display)));
- if (buf && (mode_ & Parse::TRACKMACRO)) {
+ if (buf && (mode_ & Parse::TRACKMACRO))
buf->usermacros.insert(name);
- if (optionals)
- buf->usermacros_with_opts.insert(name);
- }
}
else if (t.cs() == "newcommandx" ||
name, nargs, optionals, MacroTypeNewcommandx,
optionalValues, def, display)));
- if (buf && (mode_ & Parse::TRACKMACRO)) {
+ if (buf && (mode_ & Parse::TRACKMACRO))
buf->usermacros.insert(name);
- if (optionals)
- buf->usermacros_with_opts.insert(name);
- }
}
else if (t.cs() == "(") {
docstring const halign = parse_verbatim_item();
cell->push_back(MathAtom(new InsetMathArray(buf, name,
InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
- parse2(cell->back(), FLAG_END, mode, false);
+ parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, false);
}
else if (name == "tabular") {
Encodings::MATH_CMD | Encodings::TEXT_CMD,
is_combining, termination);
}
- if (c) {
+ if (c && buf->params().encoding().encodable(c)) {
if (termination) {
if (nextToken().cat() == catBegin) {
getToken();