diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml index cafbe46547..82bec18b72 100644 --- a/autotests/export/docbook/basic.xml +++ b/autotests/export/docbook/basic.xml @@ -424,7 +424,14 @@ I am no more code. - + + + +Michel +Foucault + + + A small paper diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 0f697ab297..253fb3759c 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -1748,13 +1748,19 @@ string citationStyleToString(const CitationStyle & cs, bool const latex) } -void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs, Buffer const & buf) +void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs, Buffer const & buf, + const std::string type) { // This function closely mimics getAuthorList, but produces DocBook instead of text. // It has been greatly simplified, as the complete list of authors is always produced. No separators are required, // as the output has a database-like shape. // constructName has also been merged within, as it becomes really simple and leads to no copy-paste. + if (! type.empty() && (type != "author" && type != "book")) { + LYXERR0("ERROR! Unexpected author contribution `" << type <<"'."); + return; + } + if (authorsString.empty()) { return; } @@ -1772,7 +1778,10 @@ void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs auto it = authors.cbegin(); auto en = authors.cend(); for (size_t i = 0; it != en; ++it, ++i) { - xs << xml::StartTag("author"); + const std::string tag = (type.empty() || type == "author") ? "author" : "othercredit"; + const std::string attr = (type == "book") ? R"(class="other" otherclass="bookauthor")" : ""; + + xs << xml::StartTag(tag, attr); xs << xml::CR(); xs << xml::StartTag("personname"); xs << xml::CR(); @@ -1812,7 +1821,7 @@ void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs xs << xml::EndTag("personname"); xs << xml::CR(); - xs << xml::EndTag("author"); + xs << xml::EndTag(tag); xs << xml::CR(); // Could add an affiliation after , but not stored in BibTeX. diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index 7a8ffb9081..aeaf0fcecc 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -37,7 +37,10 @@ CitationStyle citationStyleFromString(std::string const & latex_str, std::string citationStyleToString(CitationStyle const &, bool const latex = false); /// Transforms the information about authors into a (directly written to a XMLStream). -void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs, Buffer const & buf); +/// Type: "author" or empty means author of the entry (article, book, etc.); "book" means author of the book +/// (but not necessarily of this entry in particular). +void authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs, Buffer const & buf, + std::string type); /// Class to represent information about a BibTeX or diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index b4bf535014..d452434ab5 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1402,29 +1402,15 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const // // Example: http://tdg.docbook.org/tdg/5.1/authorgroup.html - if (hasTag("fullnames:author") || hasTag("fullbynames:bookauthor")) { - // If several author tags are present, only output one. - const docstring authorName = getTag( - hasTag("fullnames:author") ? "fullnames:author" : "fullbynames:bookauthor"); - - // Perform full parsing of the BibTeX string, dealing with the many corner cases that might - // be encountered. - authorsToDocBookAuthorGroup(authorName, xs, buffer()); - - if (hasTag("fullnames:author") && hasTag("fullbynames:bookauthor")) { - xs << XMLStream::ESCAPE_NONE << - from_utf8("\n"); - } - - // Erase all author tags that might be present, even if only one is output. - if (hasTag("fullnames:author")) { - eraseTag("fullnames:author"); - } - if (hasTag("fullbynames:bookauthor")) { - eraseTag("fullbynames:bookauthor"); - } + // Perform full parsing of the BibTeX string, dealing with the many corner cases that might + // be encountered. + if (hasTag("fullnames:author")) { + authorsToDocBookAuthorGroup(getTag("fullnames:author"), xs, buffer(), "author"); + eraseTag("fullnames:author"); + } + if (hasTag("fullbynames:bookauthor")) { + authorsToDocBookAuthorGroup(getTag("fullbynames:bookauthor"), xs, buffer(), "book"); + eraseTag("fullbynames:bookauthor"); } //