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

-
-
- - Clause 4.2  - -
+
+

introduction

+
+
note
+
+

Clause 4

+
+

Introduction

-
-

admonition

+
+ + Clause 4.2  +
- - - OUTPUT - expect(Xml::C14n.format(IsoDoc::WordConvert.new({}) - .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(<<~OUTPUT) - - - - - -
-

 

+
+

admonition

-

-
+

+ + + OUTPUT + word = <<~OUTPUT + + + + + +
+

 

+
+

+
+

+
+

+

-
-
-

- -   -

- note -
-

-
-

-
-

abstract

-
-

-
-

-
-

introduction

-
-

 

+
+

abstract

-

-
+

+

-
-
-

admonition

+
+

introduction

+
+
note
+

 

+
+

+
+

+
+
+

admonition

+
+
+

Clause 4

+
+

Introduction

-
-

Clause 4

-
-

Introduction

-
-
- - - Clause 4.2 -   - - -
+
+ + + Clause 4.2 +   + +
- - - 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
  • A
@@ -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 - - - <strong>Annex A</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Glossary</strong> - - - - A.1. - Glossary - - - - - - <strong>Annex B</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Glossary</strong> - - - - B.1. - <tab/> - Term Collection - - - B.1.1. - Term - - - - - B.2. - <tab/> - Term Collection 2 - - - B.2.1. - Term - - - - - - <strong>Annex C</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Glossary</strong> - - - - C.1. - <tab/> - Term Collection - - - C.1.1. - Term - - - - - C.2. - <tab/> - References - - - - - - <strong>Annex D</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Term Collection</strong> - - - - D.1. - - Term - - - - - + + + + Table of contents + + + + + <strong>Glossary</strong> + + + + + Annex + A + +
+ (normative) + +
+
+
+ + Glossary + +
+
+ + Annex + A + + + + + + A.1 + . + + + + Annex + A.1 + + + Glossary + + + +
+ + + <strong>Glossary</strong> + + + + + 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 + + + +
+ + + <strong>Glossary</strong> + + + + + 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 + + +
+ + + <strong>Term Collection</strong> + + + + + 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 @@ 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 end diff --git a/spec/isodoc/section_title_spec.rb b/spec/isodoc/section_title_spec.rb index 65a300b5..3f209088 100644 --- a/spec/isodoc/section_title_spec.rb +++ b/spec/isodoc/section_title_spec.rb @@ -118,7 +118,7 @@ INPUT presxml = <<~PRESXML - +