[LyX/master] DocBook: for MathML, refactor InsetMathScript::mathmlize to improve readability and lower redundancy.
Thibaut Cuvelier
tcuvelier at lyx.org
Tue May 25 01:44:58 UTC 2021
commit 5eddfe509b3c6e5e78d8e3253b2b07edb2a2d91f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Tue May 25 03:21:21 2021 +0200
DocBook: for MathML, refactor InsetMathScript::mathmlize to improve readability and lower redundancy.
---
src/mathed/InsetMathScript.cpp | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 919c0b9..831bc79 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -606,31 +606,32 @@ void InsetMathScript::mathmlize(MathMLStream & ms) const
{
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
- // FIXME: the MathMLStream should be able to give us this information
- bool l = has_limits_;
+ // FIXME: the MathMLStream should be able to give us has_limits_
+ if (!d && !u)
+ return;
+
+ const char * tag;
if (u && d)
- ms << MTag(l ? "munderover" : "msubsup");
+ tag = has_limits_ ? "munderover" : "msubsup";
else if (u)
- ms << MTag(l ? "mover" : "msup");
+ tag = has_limits_ ? "mover" : "msup";
else if (d)
- ms << MTag(l ? "munder" : "msub");
+ tag = has_limits_ ? "munder" : "msub";
+
+ ms << MTag(tag);
if (!nuc().empty())
ms << nuc();
else
ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " />";
- if (u && d)
- ms << MTag("mrow") << down() << ETag("mrow")
- << MTag("mrow") << up() << ETag("mrow")
- << ETag(l ? "munderover" : "msubsup");
- else if (u)
- ms << MTag("mrow") << up() << ETag("mrow")
- << ETag(l ? "mover" : "msup");
- else if (d)
- ms << MTag("mrow") << down() << ETag("mrow")
- << ETag(l ? "munder" : "msub");
+ if (d)
+ ms << MTag("mrow") << down() << ETag("mrow");
+ if (u)
+ ms << MTag("mrow") << up() << ETag("mrow");
+
+ ms << ETag(tag);
}
More information about the lyx-cvs
mailing list