From 26f7ba2508ebefe1aaadc577034ac2e16f0f5e97 Mon Sep 17 00:00:00 2001
From: Nick Nicholas
Date: Fri, 15 Nov 2024 01:24:08 +1100
Subject: [PATCH] rspec
---
lib/isodoc/word_function/postprocess_cover.rb | 2 -
lib/isodoc/word_function/postprocess_table.rb | 2 +-
spec/isodoc/section_spec.rb | 551 ++++++++++++------
spec/isodoc/section_title_spec.rb | 2 +-
4 files changed, 359 insertions(+), 198 deletions(-)
diff --git a/lib/isodoc/word_function/postprocess_cover.rb b/lib/isodoc/word_function/postprocess_cover.rb
index 112bcc46..fba8fc79 100644
--- a/lib/isodoc/word_function/postprocess_cover.rb
+++ b/lib/isodoc/word_function/postprocess_cover.rb
@@ -22,7 +22,6 @@ def word_cover(docxml)
cover = File.read(@wordcoverpage, encoding: "UTF-8")
cover = populate_template(cover, :word)
coverxml = to_word_xhtml_fragment(cover)
- #ins.children.first.previous = coverxml.to_xml(encoding: "US-ASCII")
ins.add_first_child coverxml.to_xml(encoding: "US-ASCII")
end
@@ -32,7 +31,6 @@ def word_intro(docxml, level)
docxml, level)
intro = populate_template(intro, :word)
introxml = to_word_xhtml_fragment(intro)
- #ins.children.first.previous = introxml.to_xml(encoding: "US-ASCII")
ins.add_first_child introxml.to_xml(encoding: "US-ASCII")
end
diff --git a/lib/isodoc/word_function/postprocess_table.rb b/lib/isodoc/word_function/postprocess_table.rb
index 6966d59d..4b6ced7a 100644
--- a/lib/isodoc/word_function/postprocess_table.rb
+++ b/lib/isodoc/word_function/postprocess_table.rb
@@ -44,7 +44,7 @@ def colgroup_widths(table)
def word_nested_tables(docxml)
docxml.xpath("//table").each do |t|
- t.xpath(".//table").reverse.each do |tt|
+ t.xpath(".//table").reverse_each do |tt|
t.next = tt.remove
end
end
diff --git a/spec/isodoc/section_spec.rb b/spec/isodoc/section_spec.rb
index 23b2337a..d0077b4f 100644
--- a/spec/isodoc/section_spec.rb
+++ b/spec/isodoc/section_spec.rb
@@ -21,115 +21,113 @@
INPUT
- expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
- .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(<<~OUTPUT)
-
-
-
-
+ html = <<~OUTPUT
+
+
+
+
+
+
+
-
-
+
+
abstract
-
-
-
-
abstract
-
-
-
-
introduction
-
-
note
-
-
Clause 4
-
-
Introduction
-
-
-
-
+
+
introduction
+
+
note
+
+
Clause 4
+
+
Introduction
-
-
-
- OUTPUT
- expect(Xml::C14n.format(IsoDoc::WordConvert.new({})
- .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(<<~OUTPUT)
-
-
-
-
-
-
+
+
+ OUTPUT
+ word = <<~OUTPUT
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
abstract
-
-
-
-
-
-
introduction
-
-
+
+
abstract
-
-
+
+
-
-
-
admonition
+
+
introduction
+
+
note
+
+
+
+
+
+
+
+
+
Clause 4
+
+
Introduction
-
-
Clause 4
-
-
Introduction
-
-
-
-
+
+
-
-
- OUTPUT
+
+
+
+ OUTPUT
+ expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
+ .convert("test", input, true)))
+ .to be_equivalent_to Xml::C14n.format(html)
+ expect(Xml::C14n.format(IsoDoc::WordConvert.new({})
+ .convert("test", input, true)))
+ .to be_equivalent_to Xml::C14n.format(word)
end
it "processes indexsect" do
input = <<~INPUT
- Glossary
+ Glossary
@@ -162,7 +160,8 @@
OUTPUT
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
- .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(output)
+ .convert("test", input, true)))
+ .to be_equivalent_to Xml::C14n.format(output)
end
it "processes annexes containing one, or more than one special sections" do
@@ -214,122 +213,285 @@
INPUT
presxml = <<~OUTPUT
-
- Table of contents
-
-
- Annex A
-
- (normative)
-
-
- Glossary
-
-
-
- A.1.
- Glossary
-
-
-
-
-
- Annex B
-
- (normative)
-
-
- Glossary
-
-
-
- B.1.
-
- Term Collection
-
-
- B.1.1.
- Term
-
-
-
-
- B.2.
-
- Term Collection 2
-
-
- B.2.1.
- Term
-
-
-
-
-
- Annex C
-
- (normative)
-
-
- Glossary
-
-
-
- C.1.
-
- Term Collection
-
-
- C.1.1.
- Term
-
-
-
-
- C.2.
-
- References
-
-
-
-
-
- Annex D
-
- (normative)
-
-
- Term Collection
-
-
-
- D.1.
-
- Term
-
-
-
-
-
+
+
+
+ Table of contents
+
+
+
+
+ Glossary
+
+
+
+
+ Annex
+ A
+
+
+ (normative)
+
+
+
+
+
+ Glossary
+
+
+
+
+ Annex
+ A
+
+
+
+
+
+ A.1
+ .
+
+
+
+ Annex
+ A.1
+
+
+ Glossary
+
+
+
+
+
+
+ Glossary
+
+
+
+
+ Annex
+ B
+
+
+ (normative)
+
+
+
+
+
+ Glossary
+
+
+
+
+ Annex
+ B
+
+
+ Term Collection
+
+
+ B.1
+ .
+
+
+
+ Term Collection
+
+
+
+ Annex
+ B.1
+
+
+
+
+ B.1.1
+ .
+
+
+
+ Annex
+ B.1.1
+
+
+ Term
+
+
+
+
+ Term Collection 2
+
+
+ B.2
+ .
+
+
+
+ Term Collection 2
+
+
+
+ Annex
+ B.2
+
+
+
+
+ B.2.1
+ .
+
+
+
+ Annex
+ B.2.1
+
+
+ Term
+
+
+
+
+
+
+ Glossary
+
+
+
+
+ Annex
+ C
+
+
+ (normative)
+
+
+
+
+
+ Glossary
+
+
+
+
+ Annex
+ C
+
+
+ Term Collection
+
+
+ C.1
+ .
+
+
+
+ Term Collection
+
+
+
+ Annex
+ C.1
+
+
+
+
+ C.1.1
+ .
+
+
+
+ Annex
+ C.1.1
+
+
+ Term
+
+
+
+
+ References
+
+
+ C.2
+ .
+
+
+
+ References
+
+
+
+ Annex
+ C.2
+
+
+
+
+
+ Term Collection
+
+
+
+
+ Annex
+ D
+
+
+ (normative)
+
+
+
+
+
+ Term Collection
+
+
+
+
+ Annex
+ D
+
+
+
+
+
+ D.1
+ .
+
+
+
+ Annex
+ D.1
+
+
+ Term
+
+
+
+
+
OUTPUT
- expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
- .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
+ expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert
+ .new(presxml_options)
+ .convert("test", input, true))))
+ .to be_equivalent_to Xml::C14n.format(presxml)
end
it "processes cross-align" do
input = <<~INPUT
-
+
- Title
+ Title
Para
- Iitre
+ Iitre
Alinée
@@ -371,6 +533,7 @@