- ParagraphList::const_iterator send;
-
- // Actual content of this paragraph.
- switch (style.latextype) {
- case LATEX_ENVIRONMENT:
- case LATEX_LIST_ENVIRONMENT:
- case LATEX_ITEM_ENVIRONMENT: {
- // There are two possibilities in this case.
- // 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(par->layout() == style);
- if (lastlay != nullptr) {
- closeItemTag(xs, *lastlay);
- if (lastlay->docbookitemwrappertag() != "NONE") {
- xs << xml::EndTag(lastlay->docbookitemwrappertag());
- xs << xml::CR();
- }
- lastlay = nullptr;
- }
-
- // this will be positive if we want to skip the
- // initial word (if it's been taken for the label).
- pos_type sep = 0;
-
- // Open a wrapper tag if needed.
- if (style.docbookitemwrappertag() != "NONE") {
- xs << xml::StartTag(style.docbookitemwrappertag(), style.docbookitemwrapperattr());
- xs << xml::CR();
- }
-
- // label output
- if (style.labeltype != LABEL_NO_LABEL &&
- style.docbookitemlabeltag() != "NONE") {
-
- if (isNormalEnv(style)) {
- // in this case, we print the label only for the first
- // paragraph (as in a theorem or an abstract).
- if (par == pbegin) {
- docstring const lbl = pbegin->params().labelString();
- if (!lbl.empty()) {
- openLabelTag(xs, style);
- xs << lbl;
- closeLabelTag(xs, style);
- } else {
- // No new line after closeLabelTag.
- xs << xml::CR();
- }
- }
- } else { // some kind of list
- if (style.labeltype == LABEL_MANUAL) {
- // Only variablelist gets here.
-
- openLabelTag(xs, style);
- sep = par->firstWordDocBook(xs, runparams);
- closeLabelTag(xs, style);
- } else {
- openLabelTag(xs, style);
- xs << par->params().labelString();
- closeLabelTag(xs, style);
- }
- }
- } // end label output
-
- // Start generating the item.
- bool wasInParagraph = runparams.docbook_in_par;
- openItemTag(xs, style);
- bool getsIntoParagraph = openInnerItemTag(xs, style);
- OutputParams rp = runparams;
- rp.docbook_in_par = wasInParagraph | getsIntoParagraph;
-
- // Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph
- // AND if the next paragraph doesn't have the same depth (if there is such a paragraph).
- // Common case: there is only the first word on the line, but there is a nested list instead
- // of more text.
- bool emptyItem = false;
- if (sep == par->size()) {
- auto next_par = par;
- ++next_par;
- if (next_par == text.paragraphs().end()) // There is no next paragraph.
- emptyItem = true;
- else // There is a next paragraph: check depth.
- emptyItem = par->params().depth() >= next_par->params().depth();
- }
-
- if (emptyItem) {
- // Avoid having an empty item, this is not valid DocBook. A single character is enough to force
- // generation of a full <para>.
- xs << ' ';
- } else {
- // Generate the rest of the paragraph, if need be.
- par->simpleDocBookOnePar(buf, xs, rp, text.outerFont(distance(begin, par)), true, true, sep);
- }
-
- ++par;
- if (getsIntoParagraph)
- closeInnerItemTag(xs, style);
-
- // We may not want to close the tag yet, in particular:
- // If we're not at the end of the item...
- if (par != pend
- // and are doing items...
- && !isNormalEnv(style)
- // and if the depth has changed...
- && par->params().depth() != origdepth) {
- // then we'll save this layout for later, and close it when
- // we get another item.
- lastlay = &style;
- } else {
- closeItemTag(xs, style);
-
- // Eventually, close the item wrapper.
- if (style.docbookitemwrappertag() != "NONE") {
- xs << xml::EndTag(style.docbookitemwrappertag());
- xs << xml::CR();
- }
+ xml::openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(),
+ style.docbookitemwrappertagtype());
+
+ // Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first
+ // character after the label.
+ pos_type sep = 0;
+ if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") {
+ if (style.labeltype == LABEL_MANUAL) {
+ // Only variablelist gets here (or similar items defined as an extension in the layout).
+ xml::openTag(xs, style.docbookitemlabeltag(), style.docbookitemlabelattr(),
+ style.docbookitemlabeltagtype());
+ sep = 1 + par->firstWordDocBook(xs, runparams);
+ xml::closeTag(xs, style.docbookitemlabeltag(), style.docbookitemlabeltagtype());
+ } else {
+ // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though.
+ docstring const lbl = par->params().labelString();
+
+ if (!lbl.empty()) {
+ xml::openTag(xs, style.docbookitemlabeltag(), style.docbookitemlabelattr(),
+ style.docbookitemlabeltagtype());
+ xs << lbl;
+ xml::closeTag(xs, style.docbookitemlabeltag(), style.docbookitemlabeltagtype());