From bf0da33c9a0af098fd9c4f1bd96bc8cb964ab878 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 20 Jan 2023 02:21:27 +0100 Subject: [PATCH] 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 e0a5d85486..96323bf6d9 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) - << "" + << ETagInline("mo") << ETag(outag); } diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp index c5c726270d..03f516dd83 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")) << "> " - << " ⁢ " - << "" + << MTagInline("mo") << "⁢" << ETagInline("mo") // ⁢ << MTag("mrow") - << "<" << from_ascii(ms.namespacedTag("mo")) << "> " - << " ⅆ " - << "" + << MTagInline("mo") << "ⅆ" << ETagInline("mo") // ⅆ << cell(1) << ETag("mrow"); } diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index 4ce758e8a4..f6f2f95b0a 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("mfrac")) << " linethickness='0'>" + << ETagInline("mo") + << MTagInline("mfrac", "linethickness='0'") << cell(0) << cell(1) - << "" - << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' stretchy='true' form='postfix'>" + << ETagInline("mfrac") + << MTagInline("mo", "fence='true' stretchy='true' form='postfix'") << rdelim - << ""; + << ETagInline("mo"); } diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp index 8204aaaef0..1e36f5a53d 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 - << ""; + ms << MTagInline(type) << xmlname << ETagInline(type); return; } } diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp index b3cbcdc57c..54a68bd558 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_) - << "" + << 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_) - << ""; + << ETagInline("mo"); } diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp index 583ae85dde..85f7e50122 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) - << ""; + << ETag("mover"); } diff --git a/src/mathed/InsetMathSideset.cpp b/src/mathed/InsetMathSideset.cpp index bf3f6cb41a..7c6c2056a9 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 5c0c2dcd4b..6c3581e501 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) - << ""; + << ETag("munderover"); else - ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>" + ms << MTag("mover", "accent='false'>") << cell(0) << cell(1) - << ""; + << ETag("mover"); } diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index 10fb087cfe..a978deb028 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 << "'; + ms << ETagInline(sym_->MathMLtype()); } diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp index 970f82456b..f8cf773105 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) - << ""; + << 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 f9b215dc62..692390f959 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) - << ""; + << ETag("munderover"); }