]> git.lyx.org Git - lyx.git/blobdiff - src/output_docbook.cpp
Remove unused Counters::copy
[lyx.git] / src / output_docbook.cpp
index 8f313e17c5e143c7ab4383f726aebe0d2f37e61c..ec11481cd966adc37edbc01e98d7b9c276bc25e5 100644 (file)
@@ -175,6 +175,10 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
        if (par == prevpar)
                prevpar = nullptr;
 
+       // If the previous paragraph is empty, don't consider it when opening wrappers.
+       if (prevpar && prevpar->empty() && !prevpar->allowEmpty())
+               prevpar = nullptr;
+
        // When should the wrapper be opened here? Only if the previous paragraph has the SAME wrapper tag
        // (usually, they won't have the same layout) and the CURRENT one allows merging.
        // The main use case is author information in several paragraphs: if the name of the author is the
@@ -221,6 +225,10 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
        if (par == nextpar)
                nextpar = nullptr;
 
+       // If the next paragraph is empty, don't consider it when closing wrappers.
+       if (nextpar && nextpar->empty() && !nextpar->allowEmpty())
+               nextpar = nullptr;
+
        // See comment in openParTag.
        Layout const & lay = par->layout();
        bool closeWrapper = lay.docbookwrappertag() != "NONE" && !runparams.docbook_ignore_wrapper;
@@ -1063,9 +1071,6 @@ void docbookParagraphs(Text const &text,
                                return;
                        });
 
-       std::stack<std::pair<int, string>> headerLevels; // Used to determine when to open/close sections: store the depth
-       // of the section and the tag that was used to open it.
-
        // Detect whether the document contains sections. If there are no sections, treatment is largely simplified.
        // In particular, there can't be an abstract, unless it is manually marked.
        bool documentHasSections;
@@ -1083,6 +1088,9 @@ void docbookParagraphs(Text const &text,
        outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
        bpit = info.epit;
 
+       std::stack<std::pair<int, string>> headerLevels; // Used to determine when to open/close sections: store the depth
+       // of the section and the tag that was used to open it.
+
        // Then, iterate through the paragraphs of this document.
        auto par = text.paragraphs().iterator_at(bpit);
        auto end = text.paragraphs().iterator_at(epit);