From 354997a7c58ff06d1f2b8b1fc126b33496e2192a Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Fri, 28 Jul 2023 23:54:17 +1000 Subject: [PATCH] use displayorder attribute to order clauses in HTML/DOC: metanorma/metanorma-ogc#567 --- Gemfile.devel | 1 + spec/isodoc/base_spec.rb | 36 ++++++++++++++------------------ spec/metanorma/processor_spec.rb | 9 ++++---- 3 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 Gemfile.devel diff --git a/Gemfile.devel b/Gemfile.devel new file mode 100644 index 00000000..9c001ec8 --- /dev/null +++ b/Gemfile.devel @@ -0,0 +1 @@ +gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "features/displayorder" diff --git a/spec/isodoc/base_spec.rb b/spec/isodoc/base_spec.rb index 9d06bda1..6d669ea5 100644 --- a/spec/isodoc/base_spec.rb +++ b/spec/isodoc/base_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Metanorma::CC do it "processes default metadata" do csdc = IsoDoc::CC::HtmlConvert.new({}) - docxml, = csdc.convert_init(<<~"INPUT", "test", true) + docxml, = csdc.convert_init(<<~INPUT, "test", true) Main Title @@ -71,7 +71,7 @@ INPUT expect(htmlencode(metadata(csdc.info(docxml, nil)).to_s - .gsub(/, :/, ",\n:"))).to be_equivalent_to <<~"OUTPUT" + .gsub(", :", ",\n:"))).to be_equivalent_to <<~OUTPUT {:accesseddate=>"XXX", :agency=>"CalConnect", :authors=>["Fred Flintstone", "Barney Rubble"], @@ -115,10 +115,10 @@ end it "processes pre" do - input = <<~"INPUT" + input = <<~INPUT - +
ABC
@@ -134,16 +134,15 @@

Foreword

ABC
-

OUTPUT end it "processes keyword" do - input = <<~"INPUT" + input = <<~INPUT - + ABC @@ -158,17 +157,17 @@

Foreword

ABC -

OUTPUT end it "processes simple terms & definitions" do - input = <<~"INPUT" + input = <<~INPUT - 1.<tab/>Terms, Definitions, Symbols and Abbreviated Terms + + 1.<tab/>Terms, Definitions, Symbols and Abbreviated Terms 1.1. Term2 @@ -182,7 +181,6 @@ .gsub(%r{^.*.*$}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR} -

1.  Terms, Definitions, Symbols and Abbreviated Terms

1.1.

@@ -194,7 +192,7 @@ end it "rearranges term headers" do - input = <<~"INPUT" + input = <<~INPUT
@@ -206,7 +204,6 @@

-

1.  Terms and definitions

For the purposes of this document, the following terms and definitions apply.

1.1.

@@ -218,7 +215,7 @@ INPUT expect(xmlpp(IsoDoc::CC::HtmlConvert.new({}) .cleanup(Nokogiri::XML(input)).to_s)) - .to be_equivalent_to xmlpp(<<~"OUTPUT") + .to be_equivalent_to xmlpp(<<~OUTPUT) @@ -231,7 +228,6 @@

-

1.  Terms and definitions

For the purposes of this document, the following terms and definitions apply.

1.1. Term2

@@ -243,7 +239,7 @@ end it "processes section names" do - input = <<~"INPUT" + input = <<~INPUT @@ -319,7 +315,7 @@ expect(xmlpp(strip_guid(IsoDoc::CC::PresentationXMLConvert.new(presxml_options) .convert("test", input, true) .gsub(%r{^.*.*$}m, "")))).to be_equivalent_to xmlpp(<<~"OUTPUT") + .gsub(%r{.*$}m, "")))).to be_equivalent_to xmlpp(<<~OUTPUT) @@ -371,6 +367,9 @@ 5.2.<tab/>Clause 4.2 + + 1.<tab/>Normative References + <strong>Appendix A</strong><br/>(normative)<br/><strong>Annex</strong> @@ -382,9 +381,6 @@ - - 1.<tab/>Normative References - Bibliography diff --git a/spec/metanorma/processor_spec.rb b/spec/metanorma/processor_spec.rb index 9fb0608b..d5f1c13e 100644 --- a/spec/metanorma/processor_spec.rb +++ b/spec/metanorma/processor_spec.rb @@ -11,7 +11,7 @@ end it "registers output formats against metanorma" do - expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT" + expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~OUTPUT [[:doc, "doc"], [:html, "html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:xml, "xml"]] OUTPUT end @@ -34,10 +34,10 @@ end it "generates HTML from IsoDoc XML" do - processor.output(<<~"INPUT", "test.xml", "test.html", :html) + processor.output(<<~INPUT, "test.xml", "test.html", :html) - + 1.<tab/>Terms, Definitions, Symbols and Abbreviated Terms 1.1. @@ -50,9 +50,8 @@ expect(xmlpp(strip_guid(File.read("test.html", encoding: "utf-8") .gsub(%r{^.*.*}m, "")))) - .to be_equivalent_to xmlpp(strip_guid(<<~"OUTPUT")) + .to be_equivalent_to xmlpp(strip_guid(<<~OUTPUT))
-

1.  Terms, Definitions, Symbols and Abbreviated Terms

1.1. Term2