diff --git a/lib/isodoc/xref.rb b/lib/isodoc/xref.rb index 2509d67b..bb2a044e 100644 --- a/lib/isodoc/xref.rb +++ b/lib/isodoc/xref.rb @@ -49,6 +49,7 @@ def parse(docxml) note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) + bookmark_anchor_names(docxml.xpath(ns(SECTIONS_XPATH))) end def ns(xpath) diff --git a/lib/isodoc/xref/xref_gen.rb b/lib/isodoc/xref/xref_gen.rb index 58200139..c6dc1b4e 100644 --- a/lib/isodoc/xref/xref_gen.rb +++ b/lib/isodoc/xref/xref_gen.rb @@ -136,5 +136,19 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) end end end + + def bookmark_anchor_names(sections) + sections.each do |s| + notes = s.xpath(ns(".//bookmark")) - s.xpath(ns(".//clause//bookmark")) - + s.xpath(ns(".//appendix//bookmark")) + notes.each do |n| + next if n["id"].nil? || n["id"].empty? + @anchors[n["id"]] = { + type: "bookmark", label: nil, value: nil, + xref: @anchors[s["id"]][:xref] } + end + bookmark_anchor_names(s.xpath(ns(CHILD_SECTIONS))) + end + end end end diff --git a/spec/isodoc/xref_spec.rb b/spec/isodoc/xref_spec.rb index 45b5b857..11bf765d 100644 --- a/spec/isodoc/xref_spec.rb +++ b/spec/isodoc/xref_spec.rb @@ -2547,6 +2547,151 @@ OUTPUT end + it "cross-references bookmarks" do + expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") + + + + + + + + + + + + + + + + + + + Preparatory + + + + + + + + Scope + + + + + + Widgets + + + + + + + + + + + + + + + + + + + + + + + + + + + INPUT + + + + + Introduction + Preparatory + Clause 1 + Clause 3.1 + Clause 3.1 + Annex A.1 + Annex A.2 + Annex A.2 + + + + + + + + Preparatory + + + + + + + + + + 1. + + Scope + + + + + + + 2. + + + + 3. + + Widgets + + + 3.1. + + + + + + + + + + + + Annex A + + (informative) + + + A.1. + + + + + + A.2. + + + + + + + + + +OUTPUT +end + it "realises subsequences" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
+ + + + + + + + +
+ +
+ Introduction + Preparatory + Clause 1 + Clause 3.1 + Clause 3.1 + Annex A.1 + Annex A.2 + Annex A.2 +