[LyX/master] MathML: improve formatting of formula in XHTML hull

Thibaut Cuvelier tcuvelier at lyx.org
Fri Jan 20 00:59:11 UTC 2023


commit f9fd652aae3634f6eb3739b372811d1e7d6558f8
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Jan 20 02:42:07 2023 +0100

    MathML: improve formatting of formula in XHTML hull
    
    Contributed by lynx: https://www.lyx.org/trac/ticket/12629
---
 src/mathed/InsetMathHull.cpp |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 746da1d..f043882 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2632,15 +2632,21 @@ docstring InsetMathHull::xhtml(XMLStream & xs, OutputParams const & op) const
 			success = true;
 		} catch (MathExportException const &) {}
 		if (success) {
+			string const name_space_declaration = "xmlns='http://www.w3.org/1998/Math/MathML'";
 			if (getType() == hullSimple)
-				xs << xml::StartTag("math",
-							"xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
-			else
-				xs << xml::StartTag("math",
-				      "display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
+			    xs << xml::StartTag("math", name_space_declaration, true);
+			else {
+	            if (!xs.isLastTagCR())
+	                 xs << xml::CR();
+	            xs << xml::StartTag("math", name_space_declaration + " display='block'", true);
+		    }
+
 			xs << XMLStream::ESCAPE_NONE
-				 << os.str()
-				 << xml::EndTag("math");
+			   << os.str();
+
+			if (!xs.isLastTagCR())
+				xs << xml::CR();
+			xs << xml::EndTag("math") << xml::CR();
 		}
 	} else if (mathtype == BufferParams::HTML) {
 		odocstringstream os;


More information about the lyx-cvs mailing list