[LyX/master] DocBook: streamline code to handle sections.
Thibaut Cuvelier
tcuvelier at lyx.org
Sat Sep 19 18:18:55 UTC 2020
commit 17b06f5336241236191d7ec9eb7643669ccfbab9
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Sun Aug 30 00:58:50 2020 +0200
DocBook: streamline code to handle sections.
---
src/output_docbook.cpp | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 38bcf05..3e37f90 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -1071,18 +1071,18 @@ void docbookParagraphs(Text const &text,
if (isLayoutSectioning(style)) {
int level = style.toclevel;
- // Need to close a previous section if it has the same level or a higher one (close <section> if opening a <h2>
- // after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
+ // Need to close a previous section if it has the same level or a higher one (close <section> if opening a
+ // <h2> after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
// - current: h2; back: h1; do not close any <section>
// - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
while (!headerLevels.empty() && level <= headerLevels.top().first) {
+ // Output the tag only if it corresponds to a legit section.
int stackLevel = headerLevels.top().first;
- docstring stackTag = from_utf8("</" + headerLevels.top().second + ">");
+ if (stackLevel != Layout::NOT_IN_TOC) {
+ xs << xml::EndTag(headerLevels.top().second);
+ xs << xml::CR();
+ }
headerLevels.pop();
-
- // Output the tag only if it corresponds to a legit section.
- if (stackLevel != Layout::NOT_IN_TOC)
- xs << XMLStream::ESCAPE_NONE << stackTag << xml::CR();
}
// Open the new section: first push it onto the stack, then output it in DocBook.
@@ -1111,11 +1111,10 @@ void docbookParagraphs(Text const &text,
}
// Write the open tag for this section.
- docstring tag = from_utf8("<" + sectionTag);
+ docstring attrs;
if (!id.empty())
- tag += from_utf8(" ") + id;
- tag += from_utf8(">");
- xs << XMLStream::ESCAPE_NONE << tag;
+ attrs = id;
+ xs << xml::StartTag(sectionTag, attrs);
xs << xml::CR();
}
}
More information about the lyx-cvs
mailing list