From 5c735ce880d1bf702df397ecfa8418e1d4590839 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Thu, 7 Oct 2021 00:07:21 +0200 Subject: [PATCH] DocBook: don't use a surrounding for rendered insets. --- src/output_docbook.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 114c258304..50b66fbac0 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -360,11 +360,13 @@ void makeParagraph( // Plain layouts must be ignored. special_case |= buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars; + // Equations do not deserve their own paragraph (DocBook allows them outside paragraphs). // Exception: any case that generates an must still get a paragraph to be valid. - special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) { + auto isEquationSpecialCase = [](InsetList::Element inset) { return inset.inset && inset.inset->asInsetMath() && inset.inset->asInsetMath()->getType() != hullSimple; - }); + }; + special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), isEquationSpecialCase); // Things that should not get into their own paragraph. (Only valid for DocBook.) static std::set lyxCodeSpecialCases = { @@ -420,6 +422,12 @@ void makeParagraph( }; special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), isFlexSpecialCase); + // If the insets should be rendered as images, enter the special case. + auto isRenderedAsImageSpecialCase = [](InsetList::Element inset) { + return inset.inset && inset.inset->getLayout().docbookrenderasimage(); + }; + special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), isRenderedAsImageSpecialCase); + // Open a paragraph if it is allowed, we are not already within a paragraph, and the insets in the paragraph do // not forbid paragraphs (aka special cases). bool const open_par = runparams.docbook_make_pars