From 4656410e04527b0e8872c51674cfa35443764f20 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 10:28:59 +1100 Subject: [PATCH] ensure that anchors are preemptively inserted in ol/li in xrefs processing, to guarantee labels are assigned: https://github.com/metanorma/isodoc/issues/617 --- lib/isodoc/presentation_function/block.rb | 3 - lib/isodoc/xref/xref_gen.rb | 10 +- spec/isodoc/presentation_xml_metadata_spec.rb | 120 +- spec/isodoc/presentation_xml_spec.rb | 1272 +++++++++++------ spec/isodoc/xref_lists_spec.rb | 534 +++---- 5 files changed, 1149 insertions(+), 790 deletions(-) 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 -

- - xmlns:sodipodi - - Figure 1 -

-
- -
- Figure 1 — Split-it-right sample divider - -
-
-
+ + + Table of contents + + + Foreword + + + Foreword + + +

+ + xmlns:sodipodi + + + Figure + 1 + +

+
+ +
+ Split-it-right sample divider + + + Figure + 1 +  — + Split-it-right sample divider + + + + 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. - <tab/> - Section - -
- Figure 1 — First -
-
-
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 - - - - <strong>Annex A</strong> - <br/> - (normative). - <tab/> - Clause - -

Text

- - - <strong>Annex A</strong> - <br/> - (normative). - <tab/> - Subclause - - “A” ‘B’ - - Clause - A - - - x - - 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 + + x + + +

Text

-
-
- - - <strong>Annex A</strong> - <br/> - (normative) - <br/> - <br/> + </clause> + </sections> + <annex id="_" inline-header="false" obligation="normative" autonum="A" displayorder="3"> + <title id="_"> <strong>Clause</strong> - - - Clause - A - - - x - - x - - -

Text

-
-
+ + + + + Annex + A + +
+ (normative) + +
+
+
+ + Clause + +
+
+ + Annex + A + + + Clause + A + + + x + + 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 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output + .sub(%r{.*}m, "")))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) - expect(Xml::C14n.format(IsoDoc::WordConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(doc) end @@ -364,14 +430,17 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - 1.<tab/>Clause -
Figure 1 +
+ + + Figure + 1 + + + + Figure + 1 + 1 2 @@ -395,14 +464,11 @@
- - - OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options.merge(output_formats: { html: "html", doc: "doc" })) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .sub(%r{.*}m, "") .gsub(%r{"data:image/emf;base64,[^"]+"}, '"data:image/emf;base64"') @@ -411,56 +477,52 @@ .to be_equivalent_to (Xml::C14n.format(output)) output = <<~OUTPUT - - - - - Table of contents - - - - - 1.<tab/>Clause -
- Figure 1 - 1 - 2 - - - - - - +
+ +
+ Figure + 1 + + + + Figure + 1 + + 1 + 2 + + + + + - - - - 3 - - - - - - 4 - - - - - - + + + + + 3 + + + + + + 4 + + + + + - - - -
-
-
-
+ + + + +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options.merge(output_formats: { html: "html" })) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .sub(%r{.*}m, "") .gsub(%r{"data:image/emf;base64,[^"]+"}, '"data:image/emf;base64"') @@ -683,24 +745,24 @@
INPUT output = <<~OUTPUT - - - - Table of contents - - - 1.<tab/>Clause -
Figure 1 - 3 -
-
-
-
+
+ + + Figure + 1 + + + + Figure + 1 + + 3 +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .gsub(%r{src="[^"]+?\.emf"}, 'src="_.emf"') .gsub(%r{src="[^"]+?\.svg"}, 'src="_.svg"')))) .to be_equivalent_to (output) @@ -721,24 +783,24 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - 1.<tab/>Clause -
Figure 1 - 3 -
-
-
-
+
+ + + Figure + 1 + + + + Figure + 1 + + 3 +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .gsub(%r{src="[^"]+?\.svg"}, 'src="_.svg"')))) .to be_equivalent_to(output) end @@ -785,72 +847,59 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - - - - 1. - <tab/> - Clause - -
    -
  1. - A1 -
      -
    1. - A2 -
        -
      1. - A3 -
          -
        1. - A4 -
            -
          1. - A5 -
              -
            1. - A6 -
                -
              1. - A7 -
                  -
                1. - A8 -
                    -
                  1. - A9 -
                      -
                    1. A0
                    2. -
                    -
                  2. -
                  -
                2. -
                -
              2. -
              -
            2. -
            -
          2. -
          -
        2. -
        -
      2. -
      -
    2. -
    -
  2. -
-
-
-
+
    +
  1. + A1 +
      +
    1. + A2 +
        +
      1. + A3 +
          +
        1. + A4 +
            +
          1. + A5 +
              +
            1. + A6 +
                +
              1. + A7 +
                  +
                1. + A8 +
                    +
                  1. + A9 +
                      +
                    1. A0
                    2. +
                    +
                  2. +
                  +
                2. +
                +
              2. +
              +
            2. +
            +
          2. +
          +
        2. +
        +
      2. +
      +
    2. +
    +
  2. +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:ol[@id = 'B1']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -860,7 +909,21 @@ - Clause + Clause + + + 1 + . + + + + Clause + + + + Clause + 1 +
  1. A1
      @@ -875,38 +938,24 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - - - 1. - <tab/> - Clause - -
        -
      1. - A1 -
          -
        • - A2 -
            -
          1. A3
          2. -
          -
        • -
        -
      2. -
      -
      -
      -
      +
        +
      1. + A1 +
          +
        • + A2 +
            +
          1. A3
          2. +
          +
        • +
        +
      2. +
      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:ol[@id = 'B1']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -952,25 +1001,112 @@ INPUT presxml = <<~OUTPUT - Section -

      Clauses 1 to 2 - text - Clauses 1 and 2 - Clauses 1, 2, and 3 - text - Clauses 1 or 2 - Clauses 1, 2, or 3 - Clauses 1 to 2 and 3 to 4 - Clause 5, a) 1) to b) 1) + Section + + + Section + + +

      + + Clauses + 1 + + to + + 2 + + + + + text + + + Clauses + 1 + + and + + 2 + + + Clauses + 1 + + , + + 2 + + , and + + 3 + + + + + text + + + Clauses + 1 + + or + + 2 + + + Clauses + 1 + + , + + 2 + + , or + + 3 + + + Clauses + 1 + + to + + 2 + + and + + 3 + + to + + 4 + + Clause + 5 + , + + a + ) + 1 + ) + + to + + b + ) + 1 + ) +

      -
      + OUTPUT - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), ) .at("//xmlns:foreword") - .to_xml)) + .to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1015,24 +1151,120 @@ INPUT presxml = <<~OUTPUT - - Section -

      箇条1箇条2text箇条1 and 箇条2 - 箇条1箇条2, and 箇条3 - text - 箇条1 or 箇条2 - 箇条1箇条2, or 箇条3 - 箇条1箇条2 and 箇条3箇条4 - 箇条5のa)の1)箇条5のb)の1) -

      -
      +

      + + 箇条 + 1 + + ~ + + 箇条 + 2 + + + + + text + + + 箇条 + 1 + + and + + 箇条 + 2 + + + 箇条 + 1 + + , + + 箇条 + 2 + + , and + + 箇条 + 3 + + + + + text + + + 箇条 + 1 + + or + + 箇条 + 2 + + + 箇条 + 1 + + , + + 箇条 + 2 + + , or + + 箇条 + 3 + + + 箇条 + 1 + + ~ + + 箇条 + 2 + + and + + 箇条 + 3 + + ~ + + 箇条 + 4 + + + 箇条 + 5 + の + a + ) + の + 1 + ) + + ~ + + 箇条 + 5 + の + b + ) + の + 1 + ) + +

      OUTPUT - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), ) - .at("//xmlns:foreword") - .to_xml)) + .at("//xmlns:p[@id = 'A']") + .to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1082,30 +1314,15 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - - - - 2. - <tab/> - Section - -

      - A - to - B -

      -
      -
      -
      +

      + A + to + B +

      OUTPUT xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true)) - xml.at("//xmlns:localized-strings")&.remove - xml.at("//xmlns:bibliography")&.remove - xml.at("//xmlns:references")&.remove + xml = xml.at("//xmlns:p[@id = 'A2']") expect(Xml::C14n.format(strip_guid(xml.to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1138,43 +1355,105 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - - - 1. - <tab/> - Section - -
      - Figure 1 — First + + Section + + + 1 + . + + + + Section + + + + Clause + 1 + +
      + First + + + Figure + 1 +  — + First + + + + Figure + 1 + +
      + + + + EXAMPLE + 1 + + + + Example + 1 + +
      + Second + + + Figure + 2 +  — + Second + + + + Figure + 2 +
      - - EXAMPLE 1 -
      - Figure 2 — Second -
      -
      - - EXAMPLE 2 -
      - Unnamed -
      -
      -
      - Figure 3 — Third + + + + + EXAMPLE + 2 + + + + Example + 2 + +
      + Unnamed + + + Unnamed + +
      - - - +
      +
      + Third + + + Figure + 3 +  — + Third + + + + Figure + 3 + +
      + OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:clause[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1200,34 +1479,63 @@ INPUT presxml = <<~OUTPUT - - Table of contents - - - - 1. - <tab/> - Scope - -

      A

      -

      - ISO 639-2 -

      -
      - - - 2. - <tab/> - Terms and definitions - -

      No terms and definitions are listed in this document.

      -
      - -
      - - + + + + Table of contents + + + + + Scope + + + 1 + . + + + + Scope + + + + Clause + 1 + +

      A

      +

      + ISO 639-2 +

      +
      + + Terms and definitions + + + 2 + . + + + + Terms and definitions + + + + Clause + 2 + +

      No terms and definitions are listed in this document.

      +
      + +
      + +
      OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert @@ -1243,32 +1551,19 @@ Scope -

      http://www.example.com

      +

      http://www.example.com

      INPUT presxml = <<~OUTPUT - - - Table of contents - - - - 1. - <tab/> - Scope - -

      - http://www.example.com -

      -
      -
      -
      +

      + http://www.example.com +

      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1296,7 +1591,7 @@ - Table of contents + Table of contents @@ -1351,14 +1646,16 @@ - Table of contents + Table of contents

      FL 1

      FL 2

      FL 3

      FL 4

      - Foreword + + ForewordForeword +

      FL 5

      FL 6

      @@ -1391,26 +1688,30 @@
      INPUT presxml = <<~OUTPUT - - Table of contents - Foreword - Table 1 - - - - - - - -
      http://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBhttp://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBwww.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBB
      -
      -
      -
      + + + + Table + 1 + + + + Table + 1 + + + + + + + + +
      http://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBhttp://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBwww.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBB
      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:table").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1447,41 +1748,47 @@ INPUT presxml = <<~OUTPUT - - Table of contents - Foreword - Table 1 - - - - - - - - - - - - - - - - - - - - - - - -
      http://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAA/​BBBBBBBBBBB­BBBBBBBBBBBBBBBBBhttp://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAABBBBBBBBBBBB­BBBBBBBBBBBBBBBBwww.​example.com/​AAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­ABBBBBBBBBBBBBBBBBBB­BBBBBBBBBaaaaaaaa_​aaaaaaaaaa.​aaaaaaaaaa.0aaaaaaaaa​<a>aaaaaaaaa​<<a>>aaaaaaaaa/​aaaaaaaaaa//​aaaaaaaaaa+​aaaaaaaaaa+​0aaaaaaaaa​{aaaaaaaaaa;​{aaaaaaaaaa​(aaaaaaaaaa(0aaaaaaaa0(aaaaaaaaa­AaaaaaaaaaaaAAaaa
      -
      + + + + Table + 1 + + + + Table + 1 + + + + + + + + + + + + + + + + + + + + + + + + +
      http://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAA/​BBBBBBBBBBB­BBBBBBBBBBBBBBBBBhttp://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAABBBBBBBBBBBB­BBBBBBBBBBBBBBBBwww.​example.com/​AAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­ABBBBBBBBBBBBBBBBBBB­BBBBBBBBBaaaaaaaa_​aaaaaaaaaa.​aaaaaaaaaa.0aaaaaaaaa​<a>aaaaaaaaa​<<a>>aaaaaaaaa/​aaaaaaaaaa//​aaaaaaaaaa+​aaaaaaaaaa+​0aaaaaaaaa​{aaaaaaaaaa;​{aaaaaaaaaa​(aaaaaaaaaa(0aaaaaaaa0(aaaaaaaaa­AaaaaaaaaaaaAAaaa
      OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options.merge(breakupurlsintables: "true")) .convert("test", input, true)) - .sub(%r{.*}m, "")) - .to be_equivalent_to (presxml) + .at("//xmlns:table").to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "realises custom charsets" do @@ -1496,16 +1803,19 @@ presxml = <<~OUTPUT weather:"OGC Weather Symbols",conscript:"Code 2000" - Table of contents + + Table of contents + - Foreword + + ForewordForeword

      OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + 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 (presxml) end @@ -1525,9 +1835,12 @@ INPUT presxml = <<~OUTPUT - Table of contents + + Table of contents + - Foreword + + ForewordForeword

      ABCDABC ABC @@ -1537,10 +1850,10 @@

      OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + 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 (presxml) end @@ -1561,23 +1874,56 @@ INPUT presxml = <<~OUTPUT - Table of contents - - Foreword -

      - Table 1 - - -
      -
      Figure 1X
      -
      -

      -
      + + + Table of contents + + + Foreword + + + Foreword + + +

      + + + + Table + 1 + + + + Table + 1 + + + + +
      +
      + + + Figure + 1 + + + + Figure + 1 + + X +
      +
      +

      +
      +
      + OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + 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 (presxml) end end diff --git a/spec/isodoc/xref_lists_spec.rb b/spec/isodoc/xref_lists_spec.rb index 93bcfe7c..7bcde789 100644 --- a/spec/isodoc/xref_lists_spec.rb +++ b/spec/isodoc/xref_lists_spec.rb @@ -324,109 +324,109 @@ .to be_equivalent_to Xml::C14n.format(output) input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - - まえがき - - - まえがき - - -

      - - 序文 - の - a - - - - 序文 - の - a - - の - 1 - - - - 序文 - の - a - - の - 1 - - の - i - - - - Preparatory - の - 1 - - - - 箇条 - 1 - の - i - - - - 箇条 - 3.1 - の - リスト - 1 - の - a - - - - 箇条 - 3.1 - の - リスト - 2 - の - I - - - - 附属書 - A.1 - の - A - - - - 附属書 - A.2 - の - リスト - 1 - の - iv - - - - 附属書 - A.2 - の - リスト - 2 - の - a - - - - Bibliographical Section - の - a - - -

      -
      + + まえがき + + + まえがき + + +

      + + 序文 + の + a + ) + + + 序文 + の + a + ) + の + 1 + ) + + + 序文 + の + a + ) + の + 1 + ) + の + i + ) + + + Preparatory + の + 1 + ) + + + 箇条 + 1 + の + i + ) + + + 箇条 + 3.1 + の + リスト + 1 + の + a + ) + + + 箇条 + 3.1 + の + リスト + 2 + の + I + ) + + + 附属書 + A.1 + の + A + ) + + + 附属書 + A.2 + の + リスト + 1 + の + iv + ) + + + 附属書 + A.2 + の + リスト + 2 + の + a + ) + + + Bibliographical Section + の + a + ) + +

      +
      OUTPUT expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) @@ -650,170 +650,170 @@ input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - まえがき - - - まえがき - - -

      - - 箇条 - 1 - の - a - - - - 箇条 - 1 - の - a - - の - 1 - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - の - A - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - の - A - - の - I - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - の - A - - の - I - - の - a - - - - 箇条 - 2 - の - リスト - 1 - の - a - - - - 箇条 - 2 - の - リスト - 1 - の - a - - の - 1 - - - - 箇条 - 2 - の - リスト - 1 - の - a - - の - 1 - - の - i - - - - 箇条 - 2 - の - リスト - 1 - の - a - - の - 1 - - の - i - - の - A - - - - 箇条 - 2 - の - リスト - 2 - の - a - - -

      -
      + まえがき + + + まえがき + + +

      + + 箇条 + 1 + の + a + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + の + I + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + の + I + ) + の + a + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + の + 1 + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + の + 1 + ) + の + i + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + + + 箇条 + 2 + の + リスト + 2 + の + a + ) + +

      + OUTPUT expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options)