From 6c3885066c1d04ead891208c3fd6db81e7dc7309 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 23:56:19 +1100 Subject: [PATCH] rspec --- spec/isodoc/footnotes_spec.rb | 205 ++++++++++++++++++++++++---------- spec/spec_helper.rb | 2 + 2 files changed, 146 insertions(+), 61 deletions(-) diff --git a/spec/isodoc/footnotes_spec.rb b/spec/isodoc/footnotes_spec.rb index 8cb150d0..f2fe8c5e 100644 --- a/spec/isodoc/footnotes_spec.rb +++ b/spec/isodoc/footnotes_spec.rb @@ -21,21 +21,39 @@ INPUT presxml = <<~INPUT - + - Foreword -

A. -

Formerly denoted as 15 % (m/m).

-

-

B. -

Formerly denoted as 15 % (m/m).

-

-

C. -

Hello! denoted as 15 % (m/m).

-

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

+ A. + +

Formerly denoted as 15 % (m/m).

+ +

+

+ B. + +

Formerly denoted as 15 % (m/m).

+ +

+

+ C. + +

Hello! denoted as 15 % (m/m).

+ +

+
-
+
INPUT html = <<~OUTPUT #{HTML_HDR} @@ -128,10 +146,10 @@

@@ -144,10 +162,10 @@ .to be_equivalent_to Xml::C14n.format(presxml) expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) .convert("test", pres_output, true)))) - .to be_equivalent_to Xml::C14n.format(html) + .to be_equivalent_to Xml::C14n.format(strip_guid(html)) expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) .convert("test", pres_output, true)))) - .to be_equivalent_to Xml::C14n.format(doc) + .to be_equivalent_to Xml::C14n.format(strip_guid(doc)) end it "processes IsoXML reviewer notes" do @@ -170,25 +188,56 @@ INPUT presxml = <<~INPUT - - - Foreword -

A.

-

B.

-

A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.

-

For further information on the Foreword, see ISO/IEC Directives, Part 2, 2016, Clause 12.

-

C.

-

Second note.

-
- Introduction -

Second note.

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

A.

+

B.

+ +

A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.

+

+ For further information on the Foreword, see + ISO/IEC Directives, Part 2, 2016, Clause 12. +

+
+

C.

+ +

Second note.

+
+
+ + Introduction + + + Introduction + + + +

Second note.

+
+
+
+
INPUT html = <<~OUTPUT

+ +

Foreword

A.

@@ -202,7 +251,7 @@
OUTPUT - doc = <<~OUTPUT + word = <<~OUTPUT

@@ -265,18 +314,18 @@

-

Second note.

+

Second note.

-

A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.

-

For further information on the Foreword, see ISO/IEC Directives, Part 2, 2016, Clause 12.

+

A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.

+

For further information on the Foreword, see ISO/IEC Directives, Part 2, 2016, Clause 12.

-

Second note.

+

Second note.

@@ -294,14 +343,16 @@ out = File.read("test.html").sub(/^.*
.*$}m, "
" ) - expect(Xml::C14n.format(out)).to be_equivalent_to Xml::C14n.format(html) + expect(Xml::C14n.format(strip_guid(out))) + .to be_equivalent_to Xml::C14n.format(html) FileUtils.rm_f "test.doc" IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }) .convert("test", pres_output, false) out = File.read("test.doc").sub(/^.*.*$}m, "") - expect(Xml::C14n.format(out)).to be_equivalent_to Xml::C14n.format(word) + expect(Xml::C14n.format(strip_guid(out))) + .to be_equivalent_to Xml::C14n.format(word) end it "processes IsoXML reviewer notes spanning list" do @@ -326,27 +377,57 @@ INPUT presxml = <<~INPUT - - - Foreword -
    -
  1. A.

    A1

  2. -
  3. B.
  4. -
      -
    • C.

      C1

    • -
    • D.
    • -
    -
-
- Introduction -

Second note.

-
-
-
+ + + + Table of contents + + + Foreword + + + Foreword + + +
    +
  1. +

    A.

    +

    A1

    +
  2. +
  3. B.
  4. +
      +
    • +

      C.

      +

      C1

      +
    • +
    • D.
    • +
    +
+
+ + Introduction + + + Introduction + + + +

Second note.

+
+
+
+
INPUT html = <<~OUTPUT

+
+

Foreword

@@ -449,13 +530,15 @@ out = File.read("test.html").sub(/^.*
.*$}m, "
" ) - expect(Xml::C14n.format(out)).to be_equivalent_to Xml::C14n.format(html) + expect(Xml::C14n.format(strip_guid(out))) + .to be_equivalent_to Xml::C14n.format(html) FileUtils.rm_f "test.doc" IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }) .convert("test", pres_output, false) - out = File.read("test.doc").sub(/^.*.*$}m, - "") - expect(Xml::C14n.format(out)).to be_equivalent_to Xml::C14n.format(word) + out = File.read("test.doc") + .sub(/^.*.*$}m, "") + expect(Xml::C14n.format(strip_guid(out))) + .to be_equivalent_to Xml::C14n.format(word) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 03b1ef06..6d81e583 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -73,6 +73,8 @@ def strip_guid(xml) .gsub(%r( name="_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' name="_"') .gsub(%r( reference="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"), ' reference="_"') .gsub(%r[ src="([^/]+)/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.], ' src="\\1/_.') + .gsub(%r[ _Ref\d+{8,10}], " _Ref") + .gsub(%r[:_Ref\d+{8,10}], ":_Ref") end HTML_HDR = <<~HEADER.freeze