]> git.lyx.org Git - features.git/commitdiff
MathML: improve formatting of formula in XHTML hull
authorThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 20 Jan 2023 01:42:07 +0000 (02:42 +0100)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 20 Jan 2023 01:45:35 +0000 (02:45 +0100)
Contributed by lynx: https://www.lyx.org/trac/ticket/12629

src/mathed/InsetMathHull.cpp

index 746da1d39f3ca1d5ea016bde89ef4aeabf9abfc0..f043882f53c2995419dde3918c8c78b09418fede 100644 (file)
@@ -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;