MathML: make InsetMathXArrow generate valid XML entities when required.

Before this, it only supported HTML entities.
This commit is contained in:
Thibaut Cuvelier 2020-11-05 02:18:47 +01:00
parent 8d33eb0351
commit 85a8664ba5

View File

@ -88,6 +88,7 @@ void InsetMathXArrow::mathmlize(MathStream & ms) const
{ {
char const * arrow; char const * arrow;
if (!ms.xmlMode()) { // Use HTML entities.
if (name_ == "xleftarrow") if (name_ == "xleftarrow")
arrow = "←"; arrow = "←";
else if (name_ == "xrightarrow") else if (name_ == "xrightarrow")
@ -122,6 +123,43 @@ void InsetMathXArrow::mathmlize(MathStream & ms) const
lyxerr << "mathmlize conversion for '" << name_ << "' not implemented" << endl; lyxerr << "mathmlize conversion for '" << name_ << "' not implemented" << endl;
LASSERT(false, arrow = "&rarr;"); LASSERT(false, arrow = "&rarr;");
} }
} else { // Use XML entities.
if (name_ == "xleftarrow")
arrow = "&#x2190;";
else if (name_ == "xrightarrow")
arrow = "&#x2192;";
else if (name_ == "xhookleftarrow")
arrow = "&#x21a9;";
else if (name_ == "xhookrightarrow")
arrow = "&#x21aa;";
else if (name_ == "xLeftarrow")
arrow = "&#x21d0;";
else if (name_ == "xRightarrow")
arrow = "&#x21d2;";
else if (name_ == "xleftrightarrow")
arrow = "&#x2194;";
else if (name_ == "xLeftrightarrow")
arrow = "&#x21d4;";
else if (name_ == "xleftharpoondown")
arrow = "&#x21bd;";
else if (name_ == "xleftharpoonup")
arrow = "&#x21bc;";
else if (name_ == "xleftrightharpoons")
arrow = "&#x21cb;";
else if (name_ == "xrightharpoondown")
arrow = "&#x21c1;";
else if (name_ == "xrightharpoonup")
arrow = "&#x21c0;";
else if (name_ == "xrightleftharpoons")
arrow = "&#x21cc;";
else if (name_ == "xmapsto")
arrow = "&#x21a6;";
else {
lyxerr << "mathmlize XML conversion for '" << name_ << "' not implemented" << endl;
LASSERT(false, arrow = "&#x2192;");
}
}
ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " accent='false' accentunder='false'>" ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " accent='false' accentunder='false'>"
<< arrow << cell(1) << cell(0) << arrow << cell(1) << cell(0)
<< "</" << from_ascii(ms.namespacedTag("munderover"))<< ">"; << "</" << from_ascii(ms.namespacedTag("munderover"))<< ">";