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
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;
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;
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);