commit bf0da33c9a0af098fd9c4f1bd96bc8cb964ab878
Author: Thibaut Cuvelier <tcuvel...@lyx.org>
Date:   Fri Jan 20 02:21:27 2023 +0100

    MathML: use standard {M/E}Tag{,Inline} instead of bespoke constructs
    
    Also, replace lspace='thinmathspace' by constructs that are not deprecated.
    
    Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathDecoration.cpp |    4 ++--
 src/mathed/InsetMathExInt.cpp      |    8 ++------
 src/mathed/InsetMathFrac.cpp       |   12 ++++++------
 src/mathed/InsetMathMacro.cpp      |    4 +---
 src/mathed/InsetMathMatrix.cpp     |    9 +++++----
 src/mathed/InsetMathOverset.cpp    |    4 ++--
 src/mathed/InsetMathSideset.cpp    |   10 +++++-----
 src/mathed/InsetMathStackrel.cpp   |    8 ++++----
 src/mathed/InsetMathSymbol.cpp     |    5 ++---
 src/mathed/InsetMathUnderset.cpp   |   10 +++++-----
 src/mathed/InsetMathXArrow.cpp     |    4 ++--
 11 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/src/mathed/InsetMathDecoration.cpp 
b/src/mathed/InsetMathDecoration.cpp
index e0a5d85..96323bf 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -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);
 }
 
diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp
index c5c7262..03f516d 100644
--- a/src/mathed/InsetMathExInt.cpp
+++ b/src/mathed/InsetMathExInt.cpp
@@ -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");
 }
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 4ce758e..f6f2f95 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -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");
 }
 
 
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 8204aaa..1e36f5a 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -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;
                }
        }
diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp
index b3cbcdc..54a68bd 100644
--- a/src/mathed/InsetMathMatrix.cpp
+++ b/src/mathed/InsetMathMatrix.cpp
@@ -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");
 }
 
 
diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp
index 583ae85..85f7e50 100644
--- a/src/mathed/InsetMathOverset.cpp
+++ b/src/mathed/InsetMathOverset.cpp
@@ -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");
 }
 
 
diff --git a/src/mathed/InsetMathSideset.cpp b/src/mathed/InsetMathSideset.cpp
index bf3f6cb..7c6c205 100644
--- a/src/mathed/InsetMathSideset.cpp
+++ b/src/mathed/InsetMathSideset.cpp
@@ -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");
 
diff --git a/src/mathed/InsetMathStackrel.cpp b/src/mathed/InsetMathStackrel.cpp
index 5c0c2dc..6c3581e 100644
--- a/src/mathed/InsetMathStackrel.cpp
+++ b/src/mathed/InsetMathStackrel.cpp
@@ -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");
 }
 
 
diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp
index 10fb087..a978deb 100644
--- a/src/mathed/InsetMathSymbol.cpp
+++ b/src/mathed/InsetMathSymbol.cpp
@@ -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());
 }
 
 
diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp
index 970f824..f8cf773 100644
--- a/src/mathed/InsetMathUnderset.cpp
+++ b/src/mathed/InsetMathUnderset.cpp
@@ -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");
 }
 
 
diff --git a/src/mathed/InsetMathXArrow.cpp b/src/mathed/InsetMathXArrow.cpp
index f9b215d..692390f 100644
--- a/src/mathed/InsetMathXArrow.cpp
+++ b/src/mathed/InsetMathXArrow.cpp
@@ -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");
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to