commit eaf94609092b35872872fb36a19ff34d5e883ef7
Author: Thibaut Cuvelier <[email protected]>
Date:   Thu Nov 26 06:52:21 2020 +0100

    DocBook: make empty bibliographies empty.
    
    Even though this means that there is no output tag.
---
 src/insets/InsetBibtex.cpp |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index 469429d..1df9928 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1089,6 +1089,13 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
 
        docstring const reflabel = buffer().B_("References");
 
+       // Check that the bibliography is not empty, to ensure that the 
document is valid.
+       if (cites.empty()) {
+               xs << XMLStream::ESCAPE_NONE << "<!-- The bibliography is 
empty! -->";
+               xs << xml::CR();
+               return;
+       }
+
        // Tell BiblioInfo our purpose (i.e. generate HTML rich text).
        CiteItem ci;
        ci.context = CiteItem::Export;
@@ -1100,7 +1107,8 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
        xs << xml::CR();
        xs << xml::StartTag("title");
        xs << reflabel;
-       xs << xml::EndTag("title") << xml::CR();
+       xs << xml::EndTag("title");
+       xs << xml::CR();
 
        // Translation between keys in each entry and DocBook tags.
        // IDs for publications; list: 
http://tdg.docbook.org/tdg/5.2/biblioid.html.
@@ -1156,11 +1164,6 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams 
const &) const
        auto vit = cites.begin();
        auto ven = cites.end();
 
-       if (vit == ven) {
-               xs << XMLStream::ESCAPE_NONE << "<!-- No entry in the 
bibliography. -->";
-               xs << xml::CR();
-       }
-
        for (; vit != ven; ++vit) {
                auto const biit = bibinfo.find(*vit);
                if (biit == bibinfo.end())
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to