commit 5b405426f140c55fff696d813230c52e2787d22a Author: Thibaut Cuvelier <tcuvel...@lyx.org> Date: Fri Sep 2 01:57:06 2022 +0200
MathML: should display "Text" MathFont using proper <mtext> tag Fixes bug 12397 Contributed by lynx --- src/mathed/InsetMathFont.cpp | 29 ++++++++++++++++------------- src/mathed/MathExtern.cpp | 15 +++++++++------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp index 2a0cb99..7a1a18d 100644 --- a/src/mathed/InsetMathFont.cpp +++ b/src/mathed/InsetMathFont.cpp @@ -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); + } } diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index 527543a..daf1719 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -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"); } } -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs