t.cs() == "def") {
if (t.cs() == "global")
getToken();
-
+
// get name
docstring name = getToken().cs();
-
+
// read parameters
int nargs = 0;
docstring pars;
++nargs;
}
nargs /= 2;
-
+
// read definition
MathData def;
parse(def, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
-
+
// is a version for display attached?
skipSpaces();
MathData display;
if (nextToken().cat() == catBegin)
parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
-
+
cell->push_back(MathAtom(new MathMacroTemplate(buf,
name, nargs, 0, MacroTypeDef,
vector<MathData>(), def, display)));
if (buf && (mode_ & Parse::TRACKMACRO))
buf->usermacros.insert(name);
}
-
+
else if (t.cs() == "newcommand" ||
t.cs() == "renewcommand" ||
t.cs() == "newlyxcommand") {
error("'}' in \\newcommand expected");
return success_;
}
-
+
// get arity
docstring const arg = getArg('[', ']');
int nargs = 0;
if (!arg.empty())
nargs = convert<int>(arg);
-
+
// optional argument given?
skipSpaces();
int optionals = 0;
parse(optionalValues[optionals], FLAG_BRACK_LAST, mode);
++optionals;
}
-
+
MathData def;
parse(def, FLAG_ITEM, InsetMath::UNDECIDED_MODE);
-
+
// is a version for display attached?
skipSpaces();
MathData display;
if (nextToken().cat() == catBegin)
parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
-
+
cell->push_back(MathAtom(new MathMacroTemplate(buf,
name, nargs, optionals, MacroTypeNewcommand,
optionalValues, def, display)));
if (buf && (mode_ & Parse::TRACKMACRO))
buf->usermacros.insert(name);
}
-
+
else if (t.cs() == "newcommandx" ||
t.cs() == "renewcommandx") {
// \newcommandx{\foo}[2][usedefault, addprefix=\global,1=default]{#1,#2}
}
} else
name = getToken().cs();
-
+
// get arity
docstring const arg = getArg('[', ']');
if (arg.empty()) {
return success_;
}
int nargs = convert<int>(arg);
-
+
// get options
int optionals = 0;
vector<MathData> optionalValues;
if (nextToken().character() == '[') {
// skip '['
getToken();
-
+
// handle 'opt=value' options, separated by ','.
skipSpaces();
while (nextToken().character() != ']' && good()) {
"for given optional parameter.");
return success_;
}
-
+
// skip '='
if (getToken().character() != '=') {
error("'=' and optional parameter value "
"expected for \\newcommandx");
return success_;
}
-
+
// get value
int optNum = max(size_t(n), optionalValues.size());
optionalValues.resize(optNum);
} else if (nextToken().cat() == catLetter) {
// we in fact ignore every non-optional
// parameter
-
+
// get option name
docstring opt;
while (nextToken().cat() == catLetter)
opt += getChar();
-
+
// value?
skipSpaces();
MathData value;
getToken();
while (nextToken().character() != ']'
&& nextToken().character() != ',')
- parse(value, FLAG_ITEM,
+ parse(value, FLAG_ITEM,
InsetMath::UNDECIDED_MODE);
}
} else {
error("option for \\newcommandx expected");
return success_;
}
-
+
// skip komma
skipSpaces();
if (nextToken().character() == ',') {
return success_;
}
}
-
+
// skip ']'
if (!good())
return success_;
else if (t.cs() == "\\") {
if (flags & FLAG_ALIGN)
return success_;
- bool added = false;
+ bool starred = false;
+ docstring arg;
if (nextToken().asInput() == "*") {
getToken();
- added = addRow(grid, cellrow, docstring(), false);
- } else {
- // skip "{}" added in front of "[" (the
- // counterpart is in InsetMathGrid::eolString())
- // skip spaces because formula could come from tex2lyx
- bool skipBraces = false;
- pushPosition();
- skipSpaces();
- if (nextToken().cat() == catBegin) {
+ starred = true;
+ } else if (nextToken().asInput() == "[")
+ arg = getArg('[', ']');
+ else if (!good())
+ error("missing token after \\\\");
+ // skip "{}" added in front of "[" (the
+ // counterpart is in InsetMathGrid::eolString())
+ // skip spaces because formula could come from tex2lyx
+ bool skipBraces = false;
+ pushPosition();
+ if (nextToken().cat() == catBegin) {
+ getToken();
+ if (nextToken().cat() == catEnd) {
getToken();
+ pushPosition();
skipSpaces();
- if (nextToken().cat() == catEnd) {
- getToken();
- skipSpaces();
- if (nextToken().asInput() == "[")
- skipBraces = true;
- }
- }
- if (skipBraces)
- dropPosition();
- else
+ if (nextToken().asInput() == "[")
+ skipBraces = true;
popPosition();
- if (good()) {
- docstring arg;
- if (!skipBraces)
- arg = getArg('[', ']');
- added = addRow(grid, cellrow, arg);
- } else
- error("missing token after \\\\");
+ }
}
+ if (skipBraces)
+ dropPosition();
+ else
+ popPosition();
+ bool const added = addRow(grid, cellrow, arg, !starred);
if (added) {
cellcol = 0;
if (grid.asHullInset())
else if (t.cs() == "cfrac") {
// allowed formats are \cfrac[pos]{num}{denom}
docstring const arg = getArg('[', ']');
- //lyxerr << "got so far: '" << arg << "'" << endl;
+ //lyxerr << "got so far: '" << arg << "'" << endl;
if (arg == "l")
cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACLEFT)));
else if (arg == "r")
else if (t.cs() == "begin") {
docstring const name = getArg('{', '}');
-
+
if (name.empty()) {
success_ = false;
error("found invalid environment");
return success_;
}
-
+
environments_.push_back(name);
if (name == "array" || name == "subarray") {
lyxerr << "found math environment `"
<< to_utf8(name)
<< "' in symbols file with unsupported inset `"
- << to_utf8(l->inset)
+ << l->inset
<< "'." << endl;
}
// create generic environment inset
} // anonymous namespace
+// FIXME This will likely need some work.
+char const * latexkeys::MathMLtype() const
+{
+ if (extra == "mathord")
+ return "mi";
+ return "mo";
+}
+
+
bool mathed_parse_cell(MathData & ar, docstring const & str, Parse::flags f)
{
return Parser(str, f, ar.buffer()).parse(ar, 0, f & Parse::TEXTMODE ?