commit 2be72a1534af143bda34b382189198667c10136b Author: Thibaut Cuvelier <tcuvel...@lyx.org> Date: Mon Feb 26 15:50:12 2024 +0100
DocBook: in bibliographies, fix support for editors. Also, add TODOs for similar problems lurking around. --- autotests/export/docbook/basic.xml | 57 +++++++++++++++++++------------------- src/insets/InsetBibtex.cpp | 38 ++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 30 deletions(-) diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml index b589ee63b9..87c951f359 100644 --- a/autotests/export/docbook/basic.xml +++ b/autotests/export/docbook/basic.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- This DocBook file was created by LyX 2.4.0dev 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> <title>I am a title</title> <author> @@ -24,43 +24,39 @@ <m:math display="inline"> <m:mrow> - <m:mrow> - <m:mspace width="6px"/> - <m:mi>w</m:mi> - <m:mi>i</m:mi> - <m:mi>t</m:mi> - <m:mi>h</m:mi> - <m:mspace width="6px"/> - <m:mi>a</m:mi> - <m:mspace width="6px"/> - <m:mi>f</m:mi> - <m:mi>o</m:mi> - <m:mi>r</m:mi> - <m:mi>m</m:mi> - <m:mi>u</m:mi> - <m:mi>l</m:mi> - <m:mi>a</m:mi> - </m:mrow> + <m:mspace width="6px"/> + <m:mi>w</m:mi> + <m:mi>i</m:mi> + <m:mi>t</m:mi> + <m:mi>h</m:mi> + <m:mspace width="6px"/> + <m:mi>a</m:mi> + <m:mspace width="6px"/> + <m:mi>f</m:mi> + <m:mi>o</m:mi> + <m:mi>r</m:mi> + <m:mi>m</m:mi> + <m:mi>u</m:mi> + <m:mi>l</m:mi> + <m:mi>a</m:mi> </m:mrow> </m:math> </inlineequation>. </para> </blockquote> -<para>Now, we're outside quotes.</para> +<para>Now, we’re outside quotes.</para> <informalequation> <alt role='tex'>Formula!</alt> <m:math display="block"> <m:mrow> - <m:mrow> - <m:mi>F</m:mi> - <m:mi>o</m:mi> - <m:mi>r</m:mi> - <m:mi>m</m:mi> - <m:mi>u</m:mi> - <m:mi>l</m:mi> - <m:mi>a</m:mi> - <m:mo>!</m:mo> - </m:mrow> + <m:mi>F</m:mi> + <m:mi>o</m:mi> + <m:mi>r</m:mi> + <m:mi>m</m:mi> + <m:mi>u</m:mi> + <m:mi>l</m:mi> + <m:mi>a</m:mi> + <m:mo>!</m:mo> </m:mrow> </m:math> </informalequation> @@ -420,6 +416,9 @@ I am no more code. </para> </personname> </author> </authorgroup> +<editor> +<personname>The editor</personname> +</editor> <bibliomisc role="note">An optional note</bibliomisc> </biblioentry> <biblioentry xml:id="small"> diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index b073f619e6..6d38631f81 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1128,6 +1128,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const make_pair("url", "uri") }; // 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> make_pair("journal", "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["publisher"] = "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>. + // TODO: some elements should be mutually exclusive; right now, all of them are output. toDocBookTag["title"] = "title"; toDocBookTag["fulltitle"] = "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["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["journaltitle"] = "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"); } + // <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> if (hasTag("abstract")) { // Split the paragraphs on new line. -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs