[LyX/master] DocBook: new lines around formulae.

Thibaut Cuvelier tcuvelier at lyx.org
Sat Sep 19 18:18:56 UTC 2020


commit 91982ee105c84395cebb637444e52342938edc39
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:21:12 2020 +0200

    DocBook: new lines around formulae.
---
 autotests/export/docbook/mathml_ns_entities.xml |   29 ++++++++++++----------
 src/mathed/InsetMathHull.cpp                    |   12 ++++++---
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/autotests/export/docbook/mathml_ns_entities.xml b/autotests/export/docbook/mathml_ns_entities.xml
index 2ee7f39..0c1509e 100644
--- a/autotests/export/docbook/mathml_ns_entities.xml
+++ b/autotests/export/docbook/mathml_ns_entities.xml
@@ -1,21 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This DocBook file was created by LyX 2.4.0dev
   See http://www.lyx.org/ for more information -->
-<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.1">
+<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
 <title>Test document</title>
 <para>A formula: 
- <informalequation>
-  <m:math>
-  <m:alt role='tex'>\Vert,\vert</m:alt>
+<informalequation>
+<alt role='tex'>\Vert,\vert</alt>
+ <m:math>
+ 
  <m:mrow>
   <m:mrow><m:mi>&#x2225;</m:mi><m:mo>,</m:mo><m:mi>&#x007C;</m:mi>
   </m:mrow>
  </m:mrow>
-  </m:math>
- </informalequation>A second formula: 
- <informalequation>
-  <m:math>
-  <m:alt role='tex'>\left\Vert \mathbf{a^{T}\,x}\right\Vert _{2}\leq x_{0}</m:alt>
+ </m:math>
+</informalequation>
+A second formula: 
+<informalequation>
+<alt role='tex'>\left\Vert \mathbf{a^{T}\,x}\right\Vert _{2}\leq x_{0}</alt>
+ <m:math>
+ 
  <m:mrow>
   <m:mrow>
    <m:msub>
@@ -45,7 +48,7 @@
    </m:msub>
   </m:mrow>
  </m:mrow>
-  </m:math>
- </informalequation></para>
-
-</article>
+ </m:math>
+</informalequation>
+</para>
+</article>
\ No newline at end of file
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index af30e8e..e7326b6 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2418,13 +2418,11 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 {
 	// Choose the tag around the MathML equation.
 	docstring name;
+	bool doCR = false;
 	if (getType() == hullSimple)
 		name = from_ascii("inlineequation");
 	else {
-		// This is a block equation, always have <informalequation> on its own line.
-		if (!xs.isLastTagCR())
-			xs << xml::CR();
-
+		doCR = true; // This is a block equation, always have <informalequation> on its own line.
 		name = from_ascii("informalequation");
 	}
 
@@ -2439,6 +2437,10 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 		}
 	}
 
+	if (doCR)
+		if (!xs.isLastTagCR())
+			xs << xml::CR();
+
 	xs << xml::StartTag(name, attr);
 	xs << xml::CR();
 
@@ -2485,6 +2487,8 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 	xs << XMLStream::ESCAPE_NONE << osmath.str();
 	xs << xml::CR();
 	xs << xml::EndTag(name);
+	if (doCR)
+		xs << xml::CR();
 }
 
 


More information about the lyx-cvs mailing list