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
This commit is contained in:
Thibaut Cuvelier 2021-05-25 02:34:04 +02:00
parent 7a210e4c9a
commit e4996026b7

View File

@ -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, // 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. // some incomplete tags might be put into the real stream.
try { 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; odocstringstream ostmp;
MathMLStream mstmp(ostmp, ms.xmlns(), ms.xmlMode()); MathMLStream mstmp(ostmp, ms.xmlns(), ms.xmlMode());
InsetMathGrid::mathmlize(mstmp); InsetMathGrid::mathmlize(mstmp);
// Then, output it (but only if the generation can be done without errors!). // Choose the display style for the formula, to be output as an attribute near the formula root.
ms << MTag("math"); std::string mathmlAttr;
if (getType() == hullSimple)
mathmlAttr = "display=\"inline\"";
else
mathmlAttr = "display=\"block\"";
// Then, output the formula.
ms << MTag("math", mathmlAttr);
ms.cr(); ms.cr();
osmath << ostmp.str(); // osmath is not a XMLStream, so no need for XMLStream::ESCAPE_NONE. osmath << ostmp.str(); // osmath is not a XMLStream, so no need for XMLStream::ESCAPE_NONE.
ms << ETag("math"); ms << ETag("math");