[LyX/master] MathML: use M/ETagInline.

Thibaut Cuvelier tcuvelier at lyx.org
Tue May 25 01:44:58 UTC 2021


commit a68e979350c13d5cd20927c67f22eab84074351f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue May 25 03:51:29 2021 +0200

    MathML: use M/ETagInline.
    
    By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0003-tag-insertion-unification-for-bold-char-delim-dots-exfunc-.patch
---
 src/mathed/InsetMath.cpp           |    4 ++--
 src/mathed/InsetMathBig.cpp        |    5 ++---
 src/mathed/InsetMathBoldSymbol.cpp |    4 ++--
 src/mathed/InsetMathChar.cpp       |    8 +++++---
 src/mathed/InsetMathDelim.cpp      |   12 ++++++------
 src/mathed/InsetMathDots.cpp       |    2 +-
 src/mathed/InsetMathExFunc.cpp     |    8 ++++----
 src/mathed/InsetMathNumber.cpp     |    4 ++--
 src/mathed/MathExtern.cpp          |    2 +-
 9 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 0d21b87..e072b48 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -205,10 +205,10 @@ void InsetMath::mathematica(MathematicaStream & os) const
 void InsetMath::mathmlize(MathMLStream & ms) const
 {
 	ms << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
-	ms << MTag("mi");
+	ms << MTagInline("mi");
 	NormalStream ns(ms.os());
 	normalize(ns);
-	ms << ETag("mi");
+	ms << ETagInline("mi");
 }
 
 
diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index 091907e..180af9b 100644
--- a/src/mathed/InsetMathBig.cpp
+++ b/src/mathed/InsetMathBig.cpp
@@ -137,10 +137,9 @@ void InsetMathBig::normalize(NormalStream & os) const
 
 void InsetMathBig::mathmlize(MathMLStream & ms) const
 {
-	ms << "<" << from_ascii(ms.namespacedTag("mo"))
-	   << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
+	ms << MTagInline("mo", "fence='true' stretchy='true' symmetric='true'>")
 	   << convertDelimToXMLEscape(delim_, ms.xmlMode())
-	   << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
+	   << ETagInline("mo");
 }
 
 
diff --git a/src/mathed/InsetMathBoldSymbol.cpp b/src/mathed/InsetMathBoldSymbol.cpp
index ba20aab..a0651ea 100644
--- a/src/mathed/InsetMathBoldSymbol.cpp
+++ b/src/mathed/InsetMathBoldSymbol.cpp
@@ -109,9 +109,9 @@ void InsetMathBoldSymbol::write(TeXMathStream & os) const
 
 void InsetMathBoldSymbol::mathmlize(MathMLStream & ms) const
 {
-	ms << "<" << from_ascii(ms.namespacedTag("mstyle")) << " mathvariant='bold'>"
+	ms << MTagInline("mstyle", "mathvariant='bold'>")
 	   << cell(0)
-	   << "</" << from_ascii(ms.namespacedTag("mstyle")) << ">";
+	   << ETagInline("mstyle");
 }
 
 
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index febc7c8..57bd816 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -252,9 +252,9 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 	}
 
 	if (!entity.empty()) {
-		ms << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+		ms << MTagInline("mo")
 		   << from_ascii(entity)
-		   << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
+		   << ETagInline("mo");
 		return;
 	}
 
@@ -263,7 +263,9 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 			? "mi" : "mo";
 	// we don't use MTag and ETag because we do not want the spacing before the end tag.
 	docstring tag = from_ascii(ms.namespacedTag(type));
-	ms << "<" << tag << ">" << char_type(char_) << "</" << tag << ">";
+	ms << MTagInline(type)
+	   << char_type(char_)
+	   << ETagInline(type);
 }
 
 
diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index e97e12c..e2bd5ac 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -181,17 +181,17 @@ void InsetMathDelim::mathematica(MathematicaStream & os) const
 
 void InsetMathDelim::mathmlize(MathMLStream & ms) const
 {
-	ms << "<" << from_ascii(ms.namespacedTag("mrow")) << ">" << "\n"
-	   << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
+	ms << MTag("mrow")
+	   << MTagInline("mo", "form='prefix' fence='true' stretchy='true' symmetric='true'>")
 	   << convertDelimToXMLEscape(left_, ms.xmlMode())
-	   << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+	   << ETagInline("mo")
 	   << "\n"
 	   << cell(0)
 	   << "\n"
-	   << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' fence='true' stretchy='true' symmetric='true'>"
+	   << MTagInline("mo", "form='postfix' fence='true' stretchy='true' symmetric='true'>")
 	   << convertDelimToXMLEscape(right_, ms.xmlMode())
-	   << "</" << from_ascii(ms.namespacedTag("mo")) << ">" << "\n"
-	   << "</" << from_ascii(ms.namespacedTag("mrow")) << ">" << "\n";
+	   << ETagInline("mo")
+	   << ETag("mrow");
 }
 
 
diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp
index 5c51511..63c54c9 100644
--- a/src/mathed/InsetMathDots.cpp
+++ b/src/mathed/InsetMathDots.cpp
@@ -105,7 +105,7 @@ void InsetMathDots::mathmlize(MathMLStream & ms) const
 			ent = "⋮";
 		else LASSERT(false, ent = "…");
 	}
-	ms << MTag("mi") << from_ascii(ent) << ETag("mi");
+	ms << MTagInline("mi") << from_ascii(ent) << ETagInline("mi");
 }
 
 
diff --git a/src/mathed/InsetMathExFunc.cpp b/src/mathed/InsetMathExFunc.cpp
index 16eb385..c450cce 100644
--- a/src/mathed/InsetMathExFunc.cpp
+++ b/src/mathed/InsetMathExFunc.cpp
@@ -124,12 +124,12 @@ void InsetMathExFunc::mathematica(MathematicaStream & os) const
 
 void InsetMathExFunc::mathmlize(MathMLStream & ms) const
 {
-	ms << "<" << from_ascii(ms.namespacedTag("mi")) << ">"
+	ms << MTagInline("mi")
 	   << name_
-       << "</" << from_ascii(ms.namespacedTag("mi")) << ">"
-	   << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+       << ETagInline("mi")
+	   << MTagInline("mo")
 	   << "⁡"
-	   << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+	   << ETagInline("mo")
 	   << cell(0);
 }
 
diff --git a/src/mathed/InsetMathNumber.cpp b/src/mathed/InsetMathNumber.cpp
index f5702ab..2ce14a7 100644
--- a/src/mathed/InsetMathNumber.cpp
+++ b/src/mathed/InsetMathNumber.cpp
@@ -70,9 +70,9 @@ void InsetMathNumber::octave(OctaveStream & os) const
 
 void InsetMathNumber::mathmlize(MathMLStream & ms) const
 {
-	ms << "<" << from_ascii(ms.namespacedTag("mn")) << ">"
+	ms << MTagInline("mn")
 	   << str_
-	   << "</" << from_ascii(ms.namespacedTag("mn")) << ">";
+	   << ETagInline("mn");
 }
 
 
diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index a473259..5c182c7 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1591,7 +1591,7 @@ void mathmlize(MathData const & dat, MathMLStream & ms)
 	MathData ar = dat;
 	extractStructure(ar, MATHML);
 	if (ar.empty())
-		ms << "<" << from_ascii(ms.namespacedTag("mrow")) << "/>";
+		ms << CTag("mrow");
 	else if (ar.size() == 1)
 		ms << ar.front();
 	else {


More information about the lyx-cvs mailing list