From e3020a6b2d240d0e1ae2aec8dfd754f6cd64dee1 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 1 Mar 2024 12:55:40 +0100 Subject: [PATCH] DocBook: support bookauthor in bibliographies. --- autotests/export/docbook/basic.bib | 11 +++++++++++ autotests/export/docbook/basic.lyx | 2 +- autotests/export/docbook/basic.xml | 31 ++++++++++++++++++++++++++++-- src/insets/InsetBibtex.cpp | 25 +++++++++++++++++++++--- 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/autotests/export/docbook/basic.bib b/autotests/export/docbook/basic.bib index 88a9fe7b14..b106326c4d 100644 --- a/autotests/export/docbook/basic.bib +++ b/autotests/export/docbook/basic.bib @@ -107,3 +107,14 @@ volume = {MCMXCVII}, month = 7, note = {An optional note} } + +@incollection{Foucault:Kritik-EN92, + author = {Foucault, Michel}, + title = {What is Critique?}, + bookauthor = {Foucault, Michel}, + booktitle = {The Politics of Truth}, + pages = {41-82}, + publisher = {Semiotext(e)}, + address = {Los Angeles}, + year = {1997} +} diff --git a/autotests/export/docbook/basic.lyx b/autotests/export/docbook/basic.lyx index d1078b9721..83b907fb54 100644 --- a/autotests/export/docbook/basic.lyx +++ b/autotests/export/docbook/basic.lyx @@ -876,7 +876,7 @@ Many things, \begin_inset CommandInset citation LatexCommand cite -key "article,book,booklet,conference,inbook,incollection" +key "article,book,booklet,conference,inbook,incollection,Foucault:Kritik-EN92" literal "false" \end_inset diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml index 2248a2cbf4..cafbe46547 100644 --- a/autotests/export/docbook/basic.xml +++ b/autotests/export/docbook/basic.xml @@ -264,7 +264,7 @@ I am no more code.
I am the sixth section and I really like bibliographies This text has references. First reference: . Second reference: . Both at the same time: , . A book: . -Many things, just testing for completeness: , , , , , . +Many things, just testing for completeness: , , , , , , .
I am the seventh section and I deal with indices @@ -358,12 +358,17 @@ I am no more code. The title of the work +4 +3 201-213 inbook The name of the publisher - +
The address of the publisher
1993 + + + @@ -372,6 +377,7 @@ I am no more code. +An optional note
The title of the work @@ -399,6 +405,27 @@ I am no more code. An optional note + +What is Critique? +41-82 +incollection + +Semiotext(e) +
Los Angeles
+1997 + +The Politics of Truth + + + + +Michel +Foucault + + + + +
A small paper -1 diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 2e6f7f7fb7..b4bf535014 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1142,6 +1142,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const // Store the mapping between BibTeX and DocBook. map toDocBookTag; toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation to DocBook: . + toDocBookTag["fullbynames:bookauthor"] = "SPECIFIC"; // No direct translation to DocBook: . toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to DocBook: . toDocBookTag["address"] = "SPECIFIC"; // No direct translation to DocBook: . toDocBookTag["editor"] = "SPECIFIC"; // No direct translation to DocBook: . @@ -1401,11 +1402,29 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const // // Example: http://tdg.docbook.org/tdg/5.1/authorgroup.html - if (hasTag("fullnames:author")) { + 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(getTag("fullnames:author"), xs, buffer()); - eraseTag("fullnames:author"); + 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"); + } } // -- 2.39.5