]> git.lyx.org Git - lyx.git/blobdiff - src/BiblioInfo.cpp
Amend 207eaeee9071cb
[lyx.git] / src / BiblioInfo.cpp
index 2a2e8d476cc327bf9ad31aa51126f873563a7789..253fb3759cbb7d50a30d9d6c701dd62330c18530 100644 (file)
@@ -1295,6 +1295,10 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
                        // to booktitle. Same for subtitle etc.
                        if (biblatex && prefixIs(key, "book"))
                                ret = (*xr)[key.substr(4)];
+                       // likewise, author is maped onto bookauthor
+                       else if (biblatex && contains(key, ":bookauthor"))
+                               ret = xr->getValueForKey(subst(key, "bookauthor", "author"),
+                                                        buf, ci, xr_dummy, maxsize);
                        if (!ret.empty())
                                // success!
                                break;
@@ -1744,15 +1748,21 @@ string citationStyleToString(const CitationStyle & cs, bool const latex)
 }
 
 
-docstring 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 docstring();
+               return;
        }
 
        // Split the input list of authors into individual authors.
@@ -1768,13 +1778,17 @@ docstring authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream
        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();
-               docstring name = *it;
+               const docstring name = *it;
 
-               // All authors go in a <personname>. If more structure is known, use it; otherwise (just "et al."), print it as such.
+               // All authors go in a <personname>. If more structure is known, use it; otherwise (just "et al."),
+               // print it as such.
                if (name == "others") {
                        xs << buf.B_(etal);
                } else {
@@ -1807,15 +1821,13 @@ docstring authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream
 
                xs << xml::EndTag("personname");
                xs << xml::CR();
-               xs << xml::EndTag("author");
+               xs << xml::EndTag(tag);
                xs << xml::CR();
 
                // Could add an affiliation after <personname>, but not stored in BibTeX.
        }
        xs << xml::EndTag("authorgroup");
        xs << xml::CR();
-
-       return docstring();
 }
 
 } // namespace lyx