From e4996026b7e890efb4a9d3c7ca5e9ce7915de1fe Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 25 May 2021 02:34:04 +0200 Subject: [PATCH] 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 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index a53b33d6bb..3ba5cdb2ce 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");