]> git.lyx.org Git - features.git/commitdiff
DocBook: ensure xml:id is not output too many times.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 11 Sep 2020 21:38:11 +0000 (23:38 +0200)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Sat, 19 Sep 2020 18:43:41 +0000 (20:43 +0200)
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
src/insets/InsetFloat.cpp
src/insets/InsetLabel.cpp

index 029162563af3ea888f04c855cea090d303aa69ac..8297c6fcdecbb0b4bec42641060dbe818d2b15b6 100644 (file)
@@ -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);
 }
 
index d68001366b60237ce87d8059e0f68710cbe47163..eaa24cb5bded4a911b54f2651ad2e1ebb99a2e8f 100644 (file)
@@ -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 {
index 2e80e26a8354e05e62ce6ef4b8462e48d540174c..5ba034456f207e564b616a8466e8cec331115569 100644 (file)
@@ -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));
        }
 }