]> git.lyx.org Git - lyx.git/commitdiff
MathML: should display "Text" MathFont using proper <mtext> tag
authorThibaut Cuvelier <tcuvelier@lyx.org>
Thu, 1 Sep 2022 23:57:06 +0000 (01:57 +0200)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Thu, 1 Sep 2022 23:57:06 +0000 (01:57 +0200)
Fixes bug 12397

Contributed by lynx

src/mathed/InsetMathFont.cpp
src/mathed/MathExtern.cpp

index 2a0cb997aa15636665d5df6b046e731b151c8eae..7a1a18d919ee82569e965ad6a7a4aac573941ee0 100644 (file)
@@ -198,22 +198,18 @@ void InsetMathFont::mathmlize(MathMLStream & ms) const
        // the fonts already in effect.
        std::string variant;
        docstring const & tag = key_->name;
-       if (tag == "mathnormal" || tag == "mathrm"
-           || tag == "text" || tag == "textnormal"
-           || tag == "textrm" || tag == "textup"
-           || tag == "textmd")
+       if (tag == "mathnormal" || tag == "mathrm")
                variant = "normal";
        else if (tag == "frak" || tag == "mathfrak")
                variant = "fraktur";
        else if (tag == "mathbf" || tag == "textbf")
                variant = "bold";
-       else if (tag == "mathbb" || tag == "mathbbm"
-                || tag == "mathds")
+       else if (tag == "mathbb" || tag == "mathbbm" || tag == "mathds")
                variant = "double-struck";
        else if (tag == "mathcal")
                variant = "script";
-       else if (tag == "mathit" || tag == "textsl"
-                || tag == "emph" || tag == "textit")
+       else if (tag == "mathit" || tag == "textsl" || tag == "emph" ||
+                       tag == "textit")
                variant = "italic";
        else if (tag == "mathsf" || tag == "textsf")
                variant = "sans-serif";
@@ -221,12 +217,19 @@ void InsetMathFont::mathmlize(MathMLStream & ms) const
                variant = "monospace";
        // no support at present for textipa, textsc, noun
 
-       if (!variant.empty())
-               ms << MTag("mstyle", "mathvariant='" + variant + "'")
-                  << cell(0)
-                  << ETag("mstyle");
-       else
+       if (tag == "text" || tag == "textnormal" || tag == "textrm" ||
+                       tag == "textup" || tag == "textmd") {
+               SetMode textmode(ms, true);
+               ms << MTagInline("mtext");
                ms << cell(0);
+               ms << ETagInline("mtext");
+       } else if (!variant.empty()) {
+               ms << MTag("mstyle", "mathvariant='" + variant + "'");
+               ms << cell(0);
+               ms << ETag("mstyle");
+       } else {
+               ms << cell(0);
+       }
 }
 
 
index 527543a33b8b4aeeb9ea69cfd399ebaee380b753..daf171981f3fdb07bfee3b4a7f0006dfbae183b1 100644 (file)
@@ -1594,15 +1594,18 @@ void mathmlize(MathData const & dat, MathMLStream & ms)
 {
        MathData ar = dat;
        extractStructure(ar, MATHML);
-       if (ar.empty())
-               ms << CTag("mrow");
-       else if (ar.size() == 1)
+       if (ar.empty()) {
+               if (!ms.inText())
+                       ms << CTag("mrow");
+       } else if (ar.size() == 1) {
                ms << ar.front();
-       else {
-               ms << MTag("mrow");
+       } else {
+               if (!ms.inText())
+                       ms << MTag("mrow");
                for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
                        (*it)->mathmlize(ms);
-               ms << ETag("mrow");
+               if (!ms.inText())
+                       ms << ETag("mrow");
        }
 }