[LyX/master] DocBook: fix bibliographies (end of <bibliography> and sections).

Thibaut Cuvelier tcuvelier at lyx.org
Sat Sep 19 18:18:55 UTC 2020


commit ec0f4885a7fd9afb007c3a4604a4e75c10ac0452
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 02:30:04 2020 +0200

    DocBook: fix bibliographies (end of <bibliography> and sections).
---
 .../export/docbook/bibliography_precooked.xml      |    3 +--
 src/output_docbook.cpp                             |   11 ++++-------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/autotests/export/docbook/bibliography_precooked.xml b/autotests/export/docbook/bibliography_precooked.xml
index 1f103bc..901abd4 100644
--- a/autotests/export/docbook/bibliography_precooked.xml
+++ b/autotests/export/docbook/bibliography_precooked.xml
@@ -5,11 +5,10 @@
 <title>William Shakespeare</title>
 <section>
 <title>Publications</title>
+</section>
 <bibliography>
 <bibliomixed xml:id='first'>First Folio. </bibliomixed>
 <bibliomixed xml:id='second'>Second Folio. </bibliomixed>
 <bibliomixed xml:id='third'>Third Folio. </bibliomixed>
 </bibliography>
-</section>
-
 </article>
\ No newline at end of file
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index a0ac96a..19bd1d8 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -393,12 +393,9 @@ void makeBibliography(
 
 	// If this is the last paragraph in a bibliography, close the bibliography tag.
 	auto const end = text.paragraphs().end();
-	bool endBibliography = par == end;
-	if (!endBibliography) {
-		auto nextpar = par;
-		++nextpar;
-		endBibliography = par->layout().latextype != LATEX_BIB_ENVIRONMENT;
-	}
+	auto nextpar = par;
+	++nextpar;
+	bool endBibliography = nextpar == end || nextpar->layout().latextype != LATEX_BIB_ENVIRONMENT;
 
 	if (endBibliography) {
 		xs << xml::EndTag("bibliography");
@@ -1124,7 +1121,7 @@ void docbookParagraphs(Text const &text,
 		auto insetsLength = distance(par->insetList().begin(), par->insetList().end());
 		if (insetsLength > 0) {
 			Inset const *firstInset = par->getInset(0);
-			if (firstInset && dynamic_cast<InsetBibtex const *>(firstInset)) {
+			if (firstInset && (firstInset->lyxCode() == BIBITEM_CODE || firstInset->lyxCode() == BIBTEX_CODE)) {
 				while (!headerLevels.empty()) {
 					int level = headerLevels.top().first;
 					docstring tag = from_utf8("</" + headerLevels.top().second + ">");


More information about the lyx-cvs mailing list