[LyX/master] DocBook: ensure xml:id is not output too many times.
Thibaut Cuvelier
tcuvelier at lyx.org
Sat Sep 19 18:18:56 UTC 2020
commit 8758000641e9014cd40581d309ded0e1cea44acf
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Fri Sep 11 23:38:11 2020 +0200
DocBook: ensure xml:id is not output too many times.
This is mostly important for subfigures, but debugging this issue showed that InsetCaption could be slightly simplified and InsetLabel should be made a tad more robust.
---
src/insets/InsetCaption.cpp | 3 +--
src/insets/InsetFloat.cpp | 2 +-
src/insets/InsetLabel.cpp | 7 +++++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp
index 0291625..8297c6f 100644
--- a/src/insets/InsetCaption.cpp
+++ b/src/insets/InsetCaption.cpp
@@ -367,8 +367,7 @@ void InsetCaption::getCaptionAsDocBook(XMLStream & xs,
return;
// Ignore full_label_, as the DocBook processor will deal with the numbering.
- InsetText::XHTMLOptions const opts =
- InsetText::WriteLabel | InsetText::WriteInnerTag;
+ InsetText::XHTMLOptions opts = InsetText::WriteInnerTag;
InsetText::docbook(xs, runparams, opts);
}
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index d680013..eaa24cb 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -583,7 +583,7 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins
xs << xml::StartTag("formalgroup", attr);
xs << xml::CR();
- xs << xml::StartTag("title", attr);
+ xs << xml::StartTag("title"); // Don't take attr here, the ID should only go in one place, not two.
if (caption) {
caption->getCaptionAsDocBook(xs, rpNoLabel);
} else {
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index 2e80e26..5ba0344 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -356,8 +356,11 @@ int InsetLabel::plaintext(odocstringstream & os,
void InsetLabel::docbook(XMLStream & xs, OutputParams const & runparams) const
{
// Output an anchor only if it has not been processed before.
- if (runparams.docbook_anchors_to_ignore.find(getParam("name")) == runparams.docbook_anchors_to_ignore.end()) {
- docstring attr = from_utf8("xml:id=\"") + xml::cleanID(getParam("name")) + from_utf8("\"");
+ docstring id = getParam("name");
+ docstring cleaned_id = xml::cleanID(id);
+ if (runparams.docbook_anchors_to_ignore.find(id) == runparams.docbook_anchors_to_ignore.end() &&
+ runparams.docbook_anchors_to_ignore.find(cleaned_id) == runparams.docbook_anchors_to_ignore.end()) {
+ docstring attr = from_utf8("xml:id=\"") + cleaned_id + from_utf8("\"");
xs << xml::CompTag("anchor", to_utf8(attr));
}
}
More information about the lyx-cvs
mailing list