DocBook: in bibliographies, fix support for editors.

Also, add TODOs for similar problems lurking around.
This commit is contained in:
Thibaut Cuvelier 2024-02-26 15:50:12 +01:00
parent 6b1441036f
commit 2be72a1534
2 changed files with 65 additions and 30 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- This DocBook file was created by LyX 2.4.0dev <!-- This DocBook file was created by LyX 2.4.0dev
See https://www.lyx.org/ for more information --> See https://www.lyx.org/ for more information -->
<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2"> <article xml:lang="en-US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
<info> <info>
<title>I am a title</title> <title>I am a title</title>
<author> <author>
@ -24,43 +24,39 @@
<m:math display="inline"> <m:math display="inline">
<m:mrow> <m:mrow>
<m:mrow> <m:mspace width="6px"/>
<m:mspace width="6px"/> <m:mi>w</m:mi>
<m:mi>w</m:mi> <m:mi>i</m:mi>
<m:mi>i</m:mi> <m:mi>t</m:mi>
<m:mi>t</m:mi> <m:mi>h</m:mi>
<m:mi>h</m:mi> <m:mspace width="6px"/>
<m:mspace width="6px"/> <m:mi>a</m:mi>
<m:mi>a</m:mi> <m:mspace width="6px"/>
<m:mspace width="6px"/> <m:mi>f</m:mi>
<m:mi>f</m:mi> <m:mi>o</m:mi>
<m:mi>o</m:mi> <m:mi>r</m:mi>
<m:mi>r</m:mi> <m:mi>m</m:mi>
<m:mi>m</m:mi> <m:mi>u</m:mi>
<m:mi>u</m:mi> <m:mi>l</m:mi>
<m:mi>l</m:mi> <m:mi>a</m:mi>
<m:mi>a</m:mi>
</m:mrow>
</m:mrow> </m:mrow>
</m:math> </m:math>
</inlineequation>. </para> </inlineequation>. </para>
</blockquote> </blockquote>
<para>Now, we're outside quotes.</para> <para>Now, we&#8217;re outside quotes.</para>
<informalequation> <informalequation>
<alt role='tex'>Formula!</alt> <alt role='tex'>Formula!</alt>
<m:math display="block"> <m:math display="block">
<m:mrow> <m:mrow>
<m:mrow> <m:mi>F</m:mi>
<m:mi>F</m:mi> <m:mi>o</m:mi>
<m:mi>o</m:mi> <m:mi>r</m:mi>
<m:mi>r</m:mi> <m:mi>m</m:mi>
<m:mi>m</m:mi> <m:mi>u</m:mi>
<m:mi>u</m:mi> <m:mi>l</m:mi>
<m:mi>l</m:mi> <m:mi>a</m:mi>
<m:mi>a</m:mi> <m:mo>!</m:mo>
<m:mo>!</m:mo>
</m:mrow>
</m:mrow> </m:mrow>
</m:math> </m:math>
</informalequation> </informalequation>
@ -420,6 +416,9 @@ I am no more code. </para>
</personname> </personname>
</author> </author>
</authorgroup> </authorgroup>
<editor>
<personname>The editor</personname>
</editor>
<bibliomisc role="note">An optional note</bibliomisc> <bibliomisc role="note">An optional note</bibliomisc>
</biblioentry> </biblioentry>
<biblioentry xml:id="small"> <biblioentry xml:id="small">

View File

@ -1128,6 +1128,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
make_pair("url", "uri") make_pair("url", "uri")
}; };
// Relations between documents. // Relations between documents.
// TODO: some elements should be mutually exclusive; right now, all of them are output.
vector<pair<string, string>> relations = { // <bibtex, docbook biblioset relation> vector<pair<string, string>> relations = { // <bibtex, docbook biblioset relation>
make_pair("journal", "journal"), make_pair("journal", "journal"),
make_pair("journaltitle", "journal"), make_pair("journaltitle", "journal"),
@ -1144,9 +1145,11 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation to DocBook: <authorgroup>. toDocBookTag["fullnames:author"] = "SPECIFIC"; // No direct translation to DocBook: <authorgroup>.
toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to DocBook: <publisher>. toDocBookTag["publisher"] = "SPECIFIC"; // No direct translation to DocBook: <publisher>.
toDocBookTag["address"] = "SPECIFIC"; // No direct translation to DocBook: <publisher>. toDocBookTag["address"] = "SPECIFIC"; // No direct translation to DocBook: <publisher>.
toDocBookTag["editor"] = "editor"; toDocBookTag["editor"] = "SPECIFIC"; // No direct translation to DocBook: <editor><personname/orgname>.
toDocBookTag["fullbynames:editor"] = "SPECIFIC"; // No direct translation to DocBook: <editor><personname/orgname>.
toDocBookTag["institution"] = "SPECIFIC"; // No direct translation to DocBook: <org>. toDocBookTag["institution"] = "SPECIFIC"; // No direct translation to DocBook: <org>.
// TODO: some elements should be mutually exclusive; right now, all of them are output.
toDocBookTag["title"] = "title"; toDocBookTag["title"] = "title";
toDocBookTag["fulltitle"] = "title"; toDocBookTag["fulltitle"] = "title";
toDocBookTag["quotetitle"] = "title"; toDocBookTag["quotetitle"] = "title";
@ -1159,6 +1162,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
toDocBookTag["year"] = "SPECIFIC"; // No direct translation to DocBook: <pubdate>. toDocBookTag["year"] = "SPECIFIC"; // No direct translation to DocBook: <pubdate>.
toDocBookTag["month"] = "SPECIFIC"; // No direct translation to DocBook: <pubdate>. toDocBookTag["month"] = "SPECIFIC"; // No direct translation to DocBook: <pubdate>.
// TODO: some elements should be mutually exclusive; right now, all of them are output.
toDocBookTag["journal"] = "SPECIFIC"; // No direct translation to DocBook: <biblioset>. toDocBookTag["journal"] = "SPECIFIC"; // No direct translation to DocBook: <biblioset>.
toDocBookTag["journaltitle"] = "SPECIFIC"; // No direct translation to DocBook: <biblioset>. toDocBookTag["journaltitle"] = "SPECIFIC"; // No direct translation to DocBook: <biblioset>.
toDocBookTag["fulljournaltitle"] = "SPECIFIC"; // No direct translation to DocBook: <biblioset>. toDocBookTag["fulljournaltitle"] = "SPECIFIC"; // No direct translation to DocBook: <biblioset>.
@ -1359,6 +1363,38 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
eraseTag("fullnames:author"); eraseTag("fullnames:author");
} }
// <editor>
// Example: http://tdg.docbook.org/tdg/5.1/editor.html
if (hasTag("editor") || hasTag("fullbynames:editor")) {
// If several editor tags are present, only output one.
const docstring editorName = getTag(hasTag("editor") ? "editor" : "fullbynames:editor");
// Arbitrarily decide that the editor is always a person. There is no reliable information in the input
// to make the distinction between a person (<personname>) and an organisation (<orgname>).
xs << xml::StartTag("editor");
xs << xml::CR();
xs << xml::StartTag("personname");
xs << editorName;
xs << xml::EndTag("personname");
xs << xml::CR();
xs << xml::EndTag("editor");
xs << xml::CR();
if (hasTag("editor") && hasTag("fullbynames:editor")) {
xs << XMLStream::ESCAPE_NONE <<
from_utf8("<!-- Several editor tags in the reference. Other editor tag: ") +
getTag("fullbynames:editor") + from_utf8(" -->\n");
}
// Erase all editor tags that might be present, even if only one is output.
if (hasTag("editor")) {
eraseTag("editor");
}
if (hasTag("fullbynames:editor")) {
eraseTag("fullbynames:editor");
}
}
// <abstract> // <abstract>
if (hasTag("abstract")) { if (hasTag("abstract")) {
// Split the paragraphs on new line. // Split the paragraphs on new line.