diff --git a/lib/isodoc/presentation_function/block.rb b/lib/isodoc/presentation_function/block.rb
index f769cd1c..1fa88d95 100644
--- a/lib/isodoc/presentation_function/block.rb
+++ b/lib/isodoc/presentation_function/block.rb
@@ -185,9 +185,6 @@ def ol_depth(node)
def ol1(elem)
elem["type"] ||= ol_depth(elem).to_s
- elem.xpath(ns("./li")).each do |li|
- li["id"] ||= "_#{UUIDTools::UUID.random_create}"
- end
elem.at(ns("./name")) and
prefix_name(elem, {}, "", "name") # copy name to fmt-name
end
diff --git a/lib/isodoc/xref/xref_gen.rb b/lib/isodoc/xref/xref_gen.rb
index dc609ce2..998124bb 100644
--- a/lib/isodoc/xref/xref_gen.rb
+++ b/lib/isodoc/xref/xref_gen.rb
@@ -149,11 +149,11 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label,
list_item_value(li, c, depth,
{ list_anchor:, prev_label:,
refer_list: depth == 1 ? refer_list : nil })
- li["id"] and @anchors[li["id"]] =
- { label: bare_label, bare_xref: "#{label})",
- xref: %[#{label}#{list_item_delim}],
- type: "listitem", refer_list:,
- container: list_anchor[:container] }
+ li["id"] ||= "_#{UUIDTools::UUID.random_create}"
+ @anchors[li["id"]] =
+ { label: bare_label, bare_xref: "#{label})", type: "listitem",
+ xref: %[#{label}#{list_item_delim}], refer_list:,
+ container: list_anchor[:container] }
(li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
list_item_anchor_names(ol, list_anchor, depth + 1, label,
refer_list)
diff --git a/spec/isodoc/presentation_xml_metadata_spec.rb b/spec/isodoc/presentation_xml_metadata_spec.rb
index dcb62ba4..2a137f5c 100644
--- a/spec/isodoc/presentation_xml_metadata_spec.rb
+++ b/spec/isodoc/presentation_xml_metadata_spec.rb
@@ -43,23 +43,46 @@
-
- Table of contents
- Foreword
-
-
- Figure 1
-
-
-
-
-
-
+
+
+ Table of contents
+
+
+ Foreword
+
+
+ Foreword
+
+
+
+
+
+ Figure
+ 1
+
+
+
+
+
+
+
OUTPUT
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert
@@ -81,22 +104,26 @@
INPUT
output = <<~OUTPUT
-
-
-
-
-
- user-css
- .green { background-color: green }
-
-
- .green { background-color: green }
-
-
+
+
+
+
+ user-css
+
+
+ user-css
+
+
+ .green { background-color: green }
+
+
+ .green { background-color: green }
+
+
OUTPUT
- expect(Xml::C14n.format(IsoDoc::PresentationXMLConvert.new(presxml_options)
+ expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true))
- .sub(%r{.*}m, ""))
+ .sub(%r{.*}m, "")))
.to be_equivalent_to Xml::C14n.format(output)
end
@@ -122,17 +149,17 @@
List of recommendations
- Table of contents
-
OUTPUT
- expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert
+ xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert
.new({ tocfigures: true,
toctables: true,
tocrecommendations: true }
.merge(presxml_options))
- .convert("test", input, true)))
- .sub(%r{.*}m, ""))
+ .convert("test", input, true))
+ xml.xpath("//xmlns:preface | //xmlns:localized-strings | //xmlns:sections")
+ .each(&:remove)
+ expect(Xml::C14n.format(strip_guid(xml.to_xml)))
.to be_equivalent_to Xml::C14n.format(presxml)
end
@@ -167,26 +194,15 @@
font1
- Table of contents
-
-
-
- 1.
-
- Section
-
-
-
-
OUTPUT
- expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert
+ xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert
.new({ fonts: "font1; font2", fontlicenseagreement: "no-install-fonts" }
.merge(presxml_options))
- .convert("test", input, true)))
- .sub(%r{.*}m, ""))
+ .convert("test", input, true))
+ xml.xpath("//xmlns:preface | //xmlns:localized-strings | //xmlns:sections")
+ .each(&:remove)
+ expect(Xml::C14n.format(strip_guid(xml.to_xml)))
.to be_equivalent_to Xml::C14n.format(presxml)
end
diff --git a/spec/isodoc/presentation_xml_spec.rb b/spec/isodoc/presentation_xml_spec.rb
index f2c52cc4..05a1ed1e 100644
--- a/spec/isodoc/presentation_xml_spec.rb
+++ b/spec/isodoc/presentation_xml_spec.rb
@@ -32,19 +32,38 @@
INPUT
output = <<~OUTPUT
-
- Table of contents
-
-
- A
-
- B
-
- C
-
+
+
+
+ Table of contents
-
-
+
+
+
+ A
+
+
+ A
+
+
+
+ B
+
+
+ B
+
+
+
+ C
+
+
+ C
+
+
+
+
+
+
OUTPUT
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert
@@ -158,64 +177,110 @@
INPUT
presxml = <<~OUTPUT
-
-
- Table of contents
-
-
-
- Annex A
-
- (normative).
-
- Clause
-
- Text
-
-
- Annex A
-
- (normative).
-
- Subclause
-
- “A” ‘B’
-
- Clause
- A
-
-
- x
-
-
- Text
+
+
+
+
+ Table of contents
+
+
+
+
+ Clause
+
+
+
+ Annex
+ A
+
+
+ (normative)
+ .
+
+
+
+ Clause
+
+
+
+ Annex
+ A
+
+ Text
+
+ Subclause
+
+
+
+ Annex
+ A
+
+
+ (normative)
+ .
+
+
+
+ Subclause
+
+
+
+ Annex
+ A
+
+ “A” ‘B’
+
+ Clause
+ A
+
+
+ x
+
+
+ Text
-
-
-
-
- Annex A
-
- (normative)
-
-
+
+
+
+
Clause
-
-
- Clause
- A
-
-
- x
-
-
- Text
-
-
+
+
+
+
+ Annex
+ A
+
+
+ (normative)
+
+
+
+
+
+ Clause
+
+
+
+
+ Annex
+ A
+
+
+ Clause
+ A
+
+
+ x
+
+
+ Text
+
+
OUTPUT
html = <<~OUTPUT
#{HTML_HDR}
@@ -223,14 +288,14 @@
Annex A
- (normative). Clause
+ (normative). Clause
Text
Annex A
- (normative). Subclause
+ (normative). Subclause
“A” ‘B’
@@ -333,16 +398,17 @@