]> git.lyx.org Git - features.git/commitdiff
MathML: use standard {M/E}Tag{,Inline} instead of bespoke constructs
authorThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 20 Jan 2023 01:21:27 +0000 (02:21 +0100)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 20 Jan 2023 01:56:55 +0000 (02:56 +0100)
Also, replace lspace='thinmathspace' by constructs that are not deprecated.

Contributed by lynx: https://www.lyx.org/trac/ticket/12629

src/mathed/InsetMathDecoration.cpp
src/mathed/InsetMathExInt.cpp
src/mathed/InsetMathFrac.cpp
src/mathed/InsetMathMacro.cpp
src/mathed/InsetMathMatrix.cpp
src/mathed/InsetMathOverset.cpp
src/mathed/InsetMathSideset.cpp
src/mathed/InsetMathStackrel.cpp
src/mathed/InsetMathSymbol.cpp
src/mathed/InsetMathUnderset.cpp
src/mathed/InsetMathXArrow.cpp

index e0a5d85486f499a64251e68810bce789d8b1c25d..96323bf6d911ab514ea0ba54cbac0f013b032f01 100644 (file)
@@ -246,9 +246,9 @@ void InsetMathDecoration::mathmlize(MathMLStream & ms) const
        std::string decoration = cur->second.entity;
        ms << MTag(outag)
           << cell(0)
-          << "<" << from_ascii(ms.namespacedTag("mo")) << " stretchy=\"true\">"
+          << MTagInline("mo", "stretchy='true'")
           << from_ascii(decoration)
-          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << ETagInline("mo")
           << ETag(outag);
 }
 
index c5c726270d54a5cd125c83c86fbd30d9b5b116e1..03f516dd8370e5ee4a69c14f34461afbce755e09 100644 (file)
@@ -152,13 +152,9 @@ void InsetMathExInt::mathmlize(MathMLStream & ms) const
        else if (upper)
                ms << ETag("msup");
        ms << cell(0)
-          << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
-          << " &#8290; "
-       << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << MTagInline("mo") << "&#8290;" << ETagInline("mo") // &InvisibleTimes;
           << MTag("mrow")
-          << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
-          << " &#8518; "
-          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << MTagInline("mo") << "&#8518;" << ETagInline("mo") // &DifferentialD;
           << cell(1)
           << ETag("mrow");
 }
index 4ce758e8a469c45600415c99f7ea3bbf9df53aa8..f6f2f95b0a7822249a12693d36b70a12ee997de4 100644 (file)
@@ -768,15 +768,15 @@ void InsetMathBinom::mathmlize(MathMLStream & ms) const
                rdelim = ']';
                break;
        }
-       ms << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' stretchy='true' form='prefix'>"
+       ms << MTagInline("mo", "fence='true' stretchy='true' form='prefix'")
           << ldelim
-          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
-          << "<" << from_ascii(ms.namespacedTag("mfrac")) << " linethickness='0'>"
+          << ETagInline("mo")
+          << MTagInline("mfrac", "linethickness='0'")
           << cell(0) << cell(1)
-       << "</" << from_ascii(ms.namespacedTag("mfrac")) << ">"
-          << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' stretchy='true' form='postfix'>"
+       << ETagInline("mfrac")
+          << MTagInline("mo", "fence='true' stretchy='true' form='postfix'")
           << rdelim
-          << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
+          << ETagInline("mo");
 }
 
 
index 8204aaaef00b7facd2bb3409f03d5dd034051596..1e36f5a53db1779e8b4458a4c280de55f762facd 100644 (file)
@@ -1306,9 +1306,7 @@ void InsetMathMacro::mathmlize(MathMLStream & ms) const
                docstring const xmlname = d->macro_->xmlname();
                if (!xmlname.empty()) {
                        char const * type = d->macro_->MathMLtype();
-                       ms << "<" << from_ascii(ms.namespacedTag(type)) << ">"
-                          << xmlname
-                          << "</" << from_ascii(ms.namespacedTag(type)) << ">";
+                       ms << MTagInline(type) << xmlname << ETagInline(type);
                        return;
                }
        }
index b3cbcdc57c3615328150d8e1fc68f3fc12a49b00..54a68bd558050f7d45598d45f5e5c1c6badaa7c9 100644 (file)
@@ -94,9 +94,10 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const
 
 void InsetMathMatrix::mathmlize(MathMLStream & ms) const
 {
-       ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+       // lspace='3/18em', but fractions are not allowed.
+       ms << MTagInline("mo", "form='prefix' fence='true' stretchy='true' symmetric='true' lspace='0.1666em'")
           << convertDelimToXMLEscape(left_)
-          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << ETagInline("mo")
           << MTag("mtable");
        for (row_type row = 0; row < nrows(); ++row) {
                ms << MTag("mtr");
@@ -113,9 +114,9 @@ void InsetMathMatrix::mathmlize(MathMLStream & ms) const
                ms << ETag("mtr");
        }
        ms << ETag("mtable")
-          << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << MTagInline("mo", "form='postfix' fence='true' stretchy='true' symmetric='true' lspace='0.1666em'")
           << convertDelimToXMLEscape(right_)
-          << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
+          << ETagInline("mo");
 }
 
 
index 583ae85ddeb8f5f98b45fac3dc42327c04ef654f..85f7e501222be80b434caf50fe771ce574d93586 100644 (file)
@@ -105,9 +105,9 @@ void InsetMathOverset::normalize(NormalStream & os) const
 
 void InsetMathOverset::mathmlize(MathMLStream & ms) const
 {
-       ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>"
+       ms << MTag("mover", "accent='false'")
           << cell(0) << cell(1)
-          << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
+          << ETag("mover");
 }
 
 
index bf3f6cb41af354460919e2b42a007a191122ecf8..7c6c2056a96b9d20a0209828bad4ce90b410395c 100644 (file)
@@ -394,25 +394,25 @@ void InsetMathSideset::mathmlize(MathMLStream & ms) const
                ms << MTag("mmultiscripts");
 
                if (nuc().empty())
-                       ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " />";
+                       ms << CTag("mrow");
                else
                        ms << MTag("mrow") << nuc() << ETag("mrow");
 
                if (br().empty() || !scriptr_)
-                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
+                       ms << CTag("none");
                else
                        ms << MTag("mrow") << br() << ETag("mrow");
                if (tr().empty() || !scriptr_)
-                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
+                       ms << CTag("none");
                else
                        ms << MTag("mrow") << tr() << ETag("mrow");
 
                if (bl().empty() || !scriptl_)
-                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
+                       ms << CTag("none");
                else
                        ms << MTag("mrow") << bl() << ETag("mrow");
                if (tl().empty() || !scriptl_)
-                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
+                       ms << CTag("none");
                else
                        ms << MTag("mrow") << tl() << ETag("mrow");
 
index 5c0c2dcd4b0238999a2464b88902f5f1ee8f722c..6c3581e501a541b7696c7e0bbc8a5d0340d096e0 100644 (file)
@@ -144,13 +144,13 @@ void InsetMathStackrel::normalize(NormalStream & os) const
 void InsetMathStackrel::mathmlize(MathMLStream & ms) const
 {
        if (nargs() > 2)
-               ms << "<" << from_ascii(ms.namespacedTag("munderover")) << ">"
+               ms << MTag("munderover")
                   << cell(0) << cell(2) << cell(1)
-                  << "</" << from_ascii(ms.namespacedTag("munderover")) << ">";
+                  << ETag("munderover");
        else
-               ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>"
+               ms << MTag("mover", "accent='false'>")
                   << cell(0) << cell(1)
-                  << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
+                  << ETag("mover");
 }
 
 
index 10fb087cfeb2f2fb8417ea6828e2929b26db3467..a978deb02840a6cac578f4ae30d0dada77116e59 100644 (file)
@@ -160,14 +160,13 @@ void InsetMathSymbol::mathmlize(MathMLStream & ms) const
 {
        // FIXME We may need to do more interesting things
        // with MathMLtype.
-       docstring tag = from_ascii(ms.namespacedTag(sym_->MathMLtype()));
-       ms << '<' << tag << ">";
+       ms << MTagInline(sym_->MathMLtype());
        if (sym_->xmlname == "x")
                // unknown so far
                ms << name();
        else
                ms << sym_->xmlname;
-       ms << "</" << tag << '>';
+       ms << ETagInline(sym_->MathMLtype());
 }
 
 
index 970f82456b79d7d89a342ae55c3ca7799d9da7f0..f8cf77310530510565bee58b3ddd0c9e4269abf4 100644 (file)
@@ -94,18 +94,18 @@ void InsetMathUnderset::normalize(NormalStream & os) const
 
 void InsetMathUnderset::mathmlize(MathMLStream & ms) const
 {
-       ms << "<" << from_ascii(ms.namespacedTag("munder")) << " accent='false'>"
+       ms << MTag("munder", "accent='false'")
           << cell(0) << cell(1)
-          << "</" << from_ascii(ms.namespacedTag("munder")) << ">";
+          << ETag("munder");
 }
 
 
 void InsetMathUnderset::htmlize(HtmlStream & os) const
 {
        os << MTag("span", "class='underset'")
-                << MTag("span") << cell(1) << ETag("span")
-                << MTag("span", "class='bottom'") << cell(0) << ETag("span")
-                << ETag("span");
+          << MTag("span") << cell(1) << ETag("span")
+          << MTag("span", "class='bottom'") << cell(0) << ETag("span")
+          << ETag("span");
 }
 
 
index f9b215dc621f439b9e393b4f75b3dfec810686ca..692390f959530e87cbb0f994b54baf91f8bd8830 100644 (file)
@@ -119,10 +119,10 @@ docstring map_latex_to(docstring latex)
 void InsetMathXArrow::mathmlize(MathMLStream & ms) const
 {
        docstring arrow = map_latex_to(name_);
-       ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " accent='false' accentunder='false'>"
+       ms << MTag("munderover", "accent='false' accentunder='false'")
           << MTagInline("mo") << arrow << ETagInline("mo")
           << cell(1) << cell(0)
-          << "</" << from_ascii(ms.namespacedTag("munderover"))<< ">";
+          << ETag("munderover");
 }