MathML: should display "Text" MathFont using proper <mtext> tag

Fixes bug 12397

Contributed by lynx
This commit is contained in:
Thibaut Cuvelier 2022-09-02 01:57:06 +02:00
parent 962785cb0f
commit 5b405426f1
2 changed files with 25 additions and 19 deletions

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

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