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,40 +88,78 @@ void InsetMathXArrow::mathmlize(MathStream & ms) const
{ {
char const * arrow; char const * arrow;
if (name_ == "xleftarrow") if (!ms.xmlMode()) { // Use HTML entities.
arrow = "←"; if (name_ == "xleftarrow")
else if (name_ == "xrightarrow") arrow = "←";
arrow = "→"; else if (name_ == "xrightarrow")
else if (name_ == "xhookleftarrow") arrow = "→";
arrow = "↩"; else if (name_ == "xhookleftarrow")
else if (name_ == "xhookrightarrow") arrow = "↩";
arrow = "↪"; else if (name_ == "xhookrightarrow")
else if (name_ == "xLeftarrow") arrow = "↪";
arrow = "⇐"; else if (name_ == "xLeftarrow")
else if (name_ == "xRightarrow") arrow = "⇐";
arrow = "⇒"; else if (name_ == "xRightarrow")
else if (name_ == "xleftrightarrow") arrow = "⇒";
arrow = "↔"; else if (name_ == "xleftrightarrow")
else if (name_ == "xLeftrightarrow") arrow = "↔";
arrow = "⇔"; else if (name_ == "xLeftrightarrow")
else if (name_ == "xleftharpoondown") arrow = "⇔";
arrow = "↽"; else if (name_ == "xleftharpoondown")
else if (name_ == "xleftharpoonup") arrow = "↽";
arrow = "↼"; else if (name_ == "xleftharpoonup")
else if (name_ == "xleftrightharpoons") arrow = "↼";
arrow = "⇋"; else if (name_ == "xleftrightharpoons")
else if (name_ == "xrightharpoondown") arrow = "⇋";
arrow = "⇁"; else if (name_ == "xrightharpoondown")
else if (name_ == "xrightharpoonup") arrow = "⇁";
arrow = "⇀"; else if (name_ == "xrightharpoonup")
else if (name_ == "xrightleftharpoons") arrow = "⇀";
arrow = "⇌"; else if (name_ == "xrightleftharpoons")
else if (name_ == "xmapsto") arrow = "⇌";
arrow = "↦"; else if (name_ == "xmapsto")
else { arrow = "↦";
lyxerr << "mathmlize conversion for '" << name_ << "' not implemented" << endl; else {
LASSERT(false, arrow = "&rarr;"); lyxerr << "mathmlize conversion for '" << name_ << "' not implemented" << endl;
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"))<< ">";