]> git.lyx.org Git - lyx.git/commitdiff
DocBook: support bookauthor in bibliographies.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 1 Mar 2024 11:55:40 +0000 (12:55 +0100)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 1 Mar 2024 12:22:34 +0000 (13:22 +0100)
autotests/export/docbook/basic.bib
autotests/export/docbook/basic.lyx
autotests/export/docbook/basic.xml
src/insets/InsetBibtex.cpp

index 88a9fe7b1410c77e3f52613a8a73cc2d37cfa17d..b106326c4d8713f542d2fe3265e2c3ae4c740bda 100644 (file)
@@ -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}
+}
index d1078b97215672fe6df648283f918212707e6b34..83b907fb542b108502e0e215504316fdd5beeb68 100644 (file)
@@ -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
index 2248a2cbf42e40b95c9719b90ab681d9a9b9f3b8..cafbe46547df2bb9542e49a9410548e51a5e17f7 100644 (file)
@@ -264,7 +264,7 @@ I am no more code. </para>
 <section>
 <title>I am the sixth section and I really like bibliographies</title>
 <para>This text has references. First reference: <biblioref linkend="big" />. Second reference: <biblioref linkend="small" />. Both at the same time: <biblioref linkend="big" />, <biblioref linkend="small" />. A book: <biblioref linkend="Gro60" />. </para>
-<para>Many things, just testing for completeness: <biblioref linkend="article" />, <biblioref linkend="book" />, <biblioref linkend="booklet" />, <biblioref linkend="conference" />, <biblioref linkend="inbook" />, <biblioref linkend="incollection" />. </para>
+<para>Many things, just testing for completeness: <biblioref linkend="article" />, <biblioref linkend="book" />, <biblioref linkend="booklet" />, <biblioref linkend="conference" />, <biblioref linkend="inbook" />, <biblioref linkend="incollection" />, <biblioref linkend="Foucault.Kritik-EN92" />. </para>
 </section>
 <section>
 <title>I am the seventh section and I deal with indices</title>
@@ -358,12 +358,17 @@ I am no more code. </para>
 </biblioentry>
 <biblioentry xml:id="inbook">
 <title>The title of the work</title>
+<volumenum>4</volumenum>
+<edition>3</edition>
 <artpagenums>201-213</artpagenums>
 <bibliomisc role="type">inbook</bibliomisc>
 <publisher>
 <publishername>The name of the publisher</publishername>
-</publisher>
+<address>The address of the publisher</address></publisher>
 <pubdate>1993</pubdate>
+<biblioset relation="book">
+<title></title>
+</biblioset>
 <authorgroup>
 <author>
 <personname>
@@ -372,6 +377,7 @@ I am no more code. </para>
 </personname>
 </author>
 </authorgroup>
+<bibliomisc role="note">An optional note</bibliomisc>
 </biblioentry>
 <biblioentry xml:id="incollection">
 <title>The title of the work</title>
@@ -399,6 +405,27 @@ I am no more code. </para>
 </editor>
 <bibliomisc role="note">An optional note</bibliomisc>
 </biblioentry>
+<biblioentry xml:id="Foucault.Kritik-EN92">
+<title>What is Critique?</title>
+<artpagenums>41-82</artpagenums>
+<bibliomisc role="type">incollection</bibliomisc>
+<publisher>
+<publishername>Semiotext(e)</publishername>
+<address>Los Angeles</address></publisher>
+<pubdate>1997</pubdate>
+<biblioset relation="book">
+<title>The Politics of Truth</title>
+</biblioset>
+<authorgroup>
+<author>
+<personname>
+<firstname>Michel</firstname>
+<surname>Foucault</surname>
+</personname>
+</author>
+</authorgroup>
+<!-- Several author tags in the reference. Other editor tag: fullbynames:bookauthor. Corresponding value: Michel Foucault -->
+</biblioentry>
 <biblioentry xml:id="small">
 <title>A small paper</title>
 <volumenum>-1</volumenum>
index 2e6f7f7fb731d226d7b132ca839a381f22f8f634..b4bf53501474642f7e40eb24c6b3f6e0d9d64414 100644 (file)
@@ -1142,6 +1142,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
        // Store the mapping between BibTeX and DocBook.
        map<string, string> toDocBookTag;
        toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation to DocBook: <authorgroup>.
+       toDocBookTag["fullbynames:bookauthor"] = "SPECIFIC"; // No direct translation to DocBook: <authorgroup>.
        toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to DocBook: <publisher>.
        toDocBookTag["address"] = "SPECIFIC"; // No direct translation to DocBook: <publisher>.
        toDocBookTag["editor"] = "SPECIFIC";  // No direct translation to DocBook: <editor><personname/orgname>.
@@ -1401,11 +1402,29 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
 
                        // <authorgroup>
                        // 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("<!-- 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");
+                               }
                        }
 
                        // <editor>