]> git.lyx.org Git - features.git/commitdiff
DocBook: make openParTag/closeTag use paragraphs instead of layouts.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Sun, 2 Aug 2020 15:35:16 +0000 (17:35 +0200)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Sat, 19 Sep 2020 18:43:37 +0000 (20:43 +0200)
Not useful per se, but will be next with checking whether the wrapper tags should be opened/closed.

src/output_docbook.cpp

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