* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author André Pönitz
+ * \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include "InsetMathRef.h"
#include "InsetMathRoot.h"
#include "InsetMathScript.h"
+#include "InsetMathSpace.h"
#include "InsetMathSplit.h"
#include "InsetMathSqrt.h"
#include "InsetMathTabular.h"
putback();
res += '{' + parse_verbatim_item() + '}';
} else
- res += t.asString();
+ res += t.asInput();
}
}
return res;
res += '{' + parse_verbatim_item() + '}';
}
else
- res += t.asString();
+ res += t.asInput();
}
}
return res;
return success_;
}
- else if (t.cat() == catOther)
- cell->push_back(MathAtom(new InsetMathChar(t.character())));
+ else if (t.cat() == catOther) {
+ char_type c = t.character();
+ if (c < 0x80 || mode_ & Parse::VERBATIM
+ || !(mode_ & Parse::USETEXT)
+ || mode == InsetMath::TEXT_MODE) {
+ cell->push_back(MathAtom(new InsetMathChar(c)));
+ } else {
+ MathAtom at = createInsetMath("text");
+ at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
+ while (nextToken().cat() == catOther
+ && nextToken().character() >= 0x80) {
+ c = getToken().character();
+ at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
+ }
+ cell->push_back(at);
+ }
+ }
else if (t.cat() == catComment) {
docstring s;
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
}
}
+
else if (t.cs() == "unitfrac") {
// Here allowed formats are \unitfrac[val]{num}{denom}
MathData ar;
parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
}
+ else if (t.cs() == "cfrac") {
+ // Here allowed formats are \cfrac[pos]{num}{denom}
+ MathData ar;
+ parse(ar, FLAG_OPTION, mode);
+ if (ar.size()) {
+ cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRAC, 3)));
+ cell->back().nucleus()->cell(2) = ar;
+ } else {
+ cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRAC)));
+ }
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+ }
+
else if (t.cs() == "xrightarrow" || t.cs() == "xleftarrow") {
cell->push_back(createInsetMath(t.cs()));
parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, InsetMath::TEXT_MODE);
}
+ else if (t.cs() == "hspace" && nextToken().character() != '*') {
+ docstring const name = t.cs();
+ docstring const arg = parse_verbatim_item();
+ Length length;
+ if (isValidLength(to_utf8(arg), &length))
+ cell->push_back(MathAtom(new InsetMathSpace(length)));
+ else {
+ // Since the Length class cannot use length variables
+ // we must not create an InsetMathSpace.
+ cell->push_back(MathAtom(new MathMacro(name)));
+ MathData ar;
+ mathed_parse_cell(ar, '{' + arg + '}');
+ cell->append(ar);
+ }
+ }
+
#if 0
else if (t.cs() == "infer") {
MathData ar;
return success_;
}
docstring rem;
- cmd = Encodings::fromLaTeXCommand(cmd, rem);
- for (size_t i = 0; i < cmd.size(); ++i)
- cell->push_back(MathAtom(new InsetMathChar(cmd[i])));
- if (rem.size()) {
- MathAtom at = createInsetMath(t.cs());
- cell->push_back(at);
- MathData ar;
- if (!mathed_parse_cell(ar, '{' + rem + '}', mode_))
- success_ = false;;
- cell->append(ar);
- }
+ do {
+ cmd = Encodings::fromLaTeXCommand(cmd, rem);
+ for (size_t i = 0; i < cmd.size(); ++i)
+ cell->push_back(MathAtom(new InsetMathChar(cmd[i])));
+ if (rem.size()) {
+ char_type c = rem[0];
+ cell->push_back(MathAtom(new InsetMathChar(c)));
+ cmd = rem.substr(1);
+ rem.clear();
+ } else
+ cmd.clear();
+ } while (cmd.size());
}
else if (t.cs().size()) {