]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.cpp
Don't create nested text-in-math environments.
[lyx.git] / src / mathed / MathParser.cpp
index c16e3cfe06d9b59fc0b48b482ac042691f595fa1..aa71b268e036a454d88822eeeab86234ff8db870 100644 (file)
@@ -910,7 +910,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cat() == catOther) {
                        char_type c = t.character();
                        if (c < 0x80 || mode_ & Parse::VERBATIM
-                           || !(mode_ & Parse::USETEXT)) {
+                           || !(mode_ & Parse::USETEXT)
+                           || mode == InsetMath::TEXT_MODE) {
                                cell->push_back(MathAtom(new InsetMathChar(c)));
                        } else {
                                MathAtom at = createInsetMath("text");
@@ -1302,6 +1303,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                        }
                }
+
                else if (t.cs() == "unitfrac") {
                        // Here allowed formats are \unitfrac[val]{num}{denom}
                        MathData ar;
@@ -1316,6 +1318,20 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        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);