[LyX/master] DocBook: for MathML, use display="block" for non-inline formulae.

Thibaut Cuvelier tcuvelier at lyx.org
Tue May 25 00:22:29 UTC 2021


commit e4996026b7e890efb4a9d3c7ca5e9ce7915de1fe
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue May 25 02:34:04 2021 +0200

    DocBook: for MathML, use display="block" for non-inline formulae.
    
    By lynx:
    https://www.lyx.org/trac/attachment/ticket/12221/0001-docbook-display-equation.patch
---
 src/mathed/InsetMathHull.cpp |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index a53b33d..3ba5cdb 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2436,13 +2436,21 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 	// temporary stream; then, if it is possible without error, then copy it back to the "real" stream. Otherwise,
 	// some incomplete tags might be put into the real stream.
 	try {
-		// First, generate the MathML expression.
+		// First, generate the MathML expression. If there is an error in the generation, this block is not fully
+		// executed, and the formula is not output to the DocBook stream.
 		odocstringstream ostmp;
 		MathMLStream mstmp(ostmp, ms.xmlns(), ms.xmlMode());
 		InsetMathGrid::mathmlize(mstmp);
 
-		// Then, output it (but only if the generation can be done without errors!).
-		ms << MTag("math");
+		// Choose the display style for the formula, to be output as an attribute near the formula root.
+		std::string mathmlAttr;
+		if (getType() == hullSimple)
+			mathmlAttr = "display=\"inline\"";
+		else
+			mathmlAttr = "display=\"block\"";
+
+		// Then, output the formula.
+		ms << MTag("math", mathmlAttr);
 		ms.cr();
 		osmath << ostmp.str(); // osmath is not a XMLStream, so no need for XMLStream::ESCAPE_NONE.
 		ms << ETag("math");


More information about the lyx-cvs mailing list