mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
DocBook: amend e3020a6b
.
Book authorship and authorship can be quite distinct. As far as I know, there is no standard way to represent book authorship in DocBook bibliographies.
This commit is contained in:
parent
3973bbcf99
commit
5c5765061f
@ -424,7 +424,14 @@ I am no more code. </para>
|
||||
</personname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
<!-- Several author tags in the reference. Other editor tag: fullbynames:bookauthor. Corresponding value: Michel Foucault -->
|
||||
<authorgroup>
|
||||
<othercredit class="other" otherclass="bookauthor">
|
||||
<personname>
|
||||
<firstname>Michel</firstname>
|
||||
<surname>Foucault</surname>
|
||||
</personname>
|
||||
</othercredit>
|
||||
</authorgroup>
|
||||
</biblioentry>
|
||||
<biblioentry xml:id="small">
|
||||
<title>A small paper</title>
|
||||
|
@ -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 <personname>, but not stored in BibTeX.
|
||||
|
@ -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 <authorgroup> (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
|
||||
|
@ -1402,29 +1402,15 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
|
||||
|
||||
// <authorgroup>
|
||||
// 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("<!-- Several author tags in the reference. Other editor tag: ") +
|
||||
from_utf8("fullbynames:bookauthor. Corresponding value: ") +
|
||||
getTag("fullbynames:bookauthor") + 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");
|
||||
}
|
||||
|
||||
// <editor>
|
||||
|
Loading…
Reference in New Issue
Block a user