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
This commit is contained in:
Thibaut Cuvelier 2023-01-20 02:21:27 +01:00
parent 598c6a0a87
commit bf0da33c9a
11 changed files with 36 additions and 42 deletions

View 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);
}

View 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");
}

View 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");
}

View 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;
}
}

View 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");
}

View 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");
}

View 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");

View 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");
}

View 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());
}

View File

@ -94,9 +94,9 @@ 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");
}

View 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");
}