Revert "DocBook: make openParTag/closeTag use paragraphs instead of layouts."

This reverts commit 3d7c802c22.
This commit is contained in:
Thibaut Cuvelier 2020-08-03 22:56:55 +02:00
parent 347d3557b2
commit 21c92c8a12

View File

@ -189,10 +189,8 @@ namespace {
// convenience functions // convenience functions
void openParTag(XMLStream & xs, Paragraph const & par) void openParTag(XMLStream & xs, Layout const & lay)
{ {
Layout const & lay = par.layout();
if (lay.docbookwrappertag() != "NONE") if (lay.docbookwrappertag() != "NONE")
xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr());
@ -207,10 +205,8 @@ void openParTag(XMLStream & xs, Paragraph const & par)
} }
void closeTag(XMLStream & xs, Paragraph const & par) void closeTag(XMLStream & xs, Layout const & lay)
{ {
Layout const & lay = par.layout();
if (lay.docbookitemtag() != "NONE") if (lay.docbookitemtag() != "NONE")
xs << xml::EndTag(lay.docbookitemtag()); xs << xml::EndTag(lay.docbookitemtag());
@ -298,8 +294,8 @@ ParagraphList::const_iterator findEndOfEnvironment(
ParagraphList::const_iterator const & pend) ParagraphList::const_iterator const & pend)
{ {
ParagraphList::const_iterator p = pstart; ParagraphList::const_iterator p = pstart;
Layout const &bstyle = p->layout();
size_t const depth = p->params().depth(); size_t const depth = p->params().depth();
for (++p; p != pend; ++p) { for (++p; p != pend; ++p) {
Layout const &style = p->layout(); Layout const &style = p->layout();
// It shouldn't happen that e.g. a section command occurs inside // It shouldn't happen that e.g. a section command occurs inside
@ -319,10 +315,9 @@ ParagraphList::const_iterator findEndOfEnvironment(
// FIXME I am not sure about the first check. // FIXME I am not sure about the first check.
// Surely we *could* have different layouts that count as // Surely we *could* have different layouts that count as
// LATEX_PARAGRAPH, right? // LATEX_PARAGRAPH, right?
if (style.latextype == LATEX_PARAGRAPH || style != p->layout()) if (style.latextype == LATEX_PARAGRAPH || style != bstyle)
return p; return p;
} }
return pend; return pend;
} }
@ -402,6 +397,8 @@ ParagraphList::const_iterator makeParagraphs(
ParagraphList::const_iterator const begin = text.paragraphs().begin(); ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin; ParagraphList::const_iterator par = pbegin;
for (; par != pend; ++par) { for (; par != pend; ++par) {
Layout const &lay = par->layout();
// We want to open the paragraph tag if: // We want to open the paragraph tag if:
// (i) the current layout permits multiple paragraphs // (i) the current layout permits multiple paragraphs
// (ii) we are either not already inside a paragraph (HTMLIsBlock) OR // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR
@ -431,7 +428,7 @@ ParagraphList::const_iterator makeParagraphs(
} }
// Plain layouts must be ignored. // Plain layouts must be ignored.
if (!special_case && buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars) if (!special_case && buf.params().documentClass().isPlainLayout(lay) && !runparams.docbook_force_pars)
special_case = true; special_case = true;
// TODO: Could get rid of this with a DocBook equivalent to htmlisblock? // TODO: Could get rid of this with a DocBook equivalent to htmlisblock?
if (!special_case && par->size() == 1 && par->getInset(0)) { if (!special_case && par->size() == 1 && par->getInset(0)) {
@ -484,12 +481,12 @@ ParagraphList::const_iterator makeParagraphs(
if (!cleaned.empty()) { if (!cleaned.empty()) {
if (open_par) if (open_par)
openParTag(xs, *par); openParTag(xs, lay);
xs << XMLStream::ESCAPE_NONE << os2.str(); xs << XMLStream::ESCAPE_NONE << os2.str();
if (close_par) { if (close_par) {
closeTag(xs, *par); closeTag(xs, lay);
xs << xml::CR(); xs << xml::CR();
} }
} }
@ -513,12 +510,13 @@ ParagraphList::const_iterator makeEnvironment(
ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend) ParagraphList::const_iterator const & pend)
{ {
auto const begin = text.paragraphs().begin(); ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin; ParagraphList::const_iterator par = pbegin;
Layout const &bstyle = par->layout();
depth_type const origdepth = pbegin->params().depth(); depth_type const origdepth = pbegin->params().depth();
// open tag for this environment // open tag for this environment
openParTag(xs, *par); openParTag(xs, bstyle);
xs << xml::CR(); xs << xml::CR();
// we will on occasion need to remember a layout from before. // we will on occasion need to remember a layout from before.
@ -537,7 +535,7 @@ ParagraphList::const_iterator makeEnvironment(
// One is that we are still in the environment in which we // One is that we are still in the environment in which we
// started---which we will be if the depth is the same. // started---which we will be if the depth is the same.
if (par->params().depth() == origdepth) { if (par->params().depth() == origdepth) {
LATTEST(par->layout() == style); LATTEST(bstyle == style);
if (lastlay != nullptr) { if (lastlay != nullptr) {
closeItemTag(xs, *lastlay); closeItemTag(xs, *lastlay);
if (lastlay->docbookitemwrappertag() != "NONE") { if (lastlay->docbookitemwrappertag() != "NONE") {
@ -672,7 +670,7 @@ ParagraphList::const_iterator makeEnvironment(
xs << xml::CR(); xs << xml::CR();
} }
} }
closeTag(xs, *par); closeTag(xs, bstyle);
xs << xml::CR(); xs << xml::CR();
return pend; return pend;
} }
@ -685,15 +683,16 @@ void makeCommand(
Text const & text, Text const & text,
ParagraphList::const_iterator const & pbegin) ParagraphList::const_iterator const & pbegin)
{ {
Layout const &style = pbegin->layout();
// No need for labels, as they are handled by DocBook tags. // No need for labels, as they are handled by DocBook tags.
openParTag(xs, *pbegin); openParTag(xs, style);
auto const begin = text.paragraphs().begin(); ParagraphList::const_iterator const begin = text.paragraphs().begin();
pbegin->simpleDocBookOnePar(buf, xs, runparams, pbegin->simpleDocBookOnePar(buf, xs, runparams,
text.outerFont(distance(begin, pbegin))); text.outerFont(distance(begin, pbegin)));
closeTag(xs, style);
closeTag(xs, *pbegin);
xs << xml::CR(); xs << xml::CR();
} }