metanorma-iso 1.9.6 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ubuntu.yml +41 -0
  3. data/Gemfile +3 -4
  4. data/Makefile +44 -0
  5. data/Rakefile +1 -1
  6. data/bin/rspec +1 -2
  7. data/lib/asciidoctor/iso/cleanup.rb +7 -6
  8. data/lib/asciidoctor/iso/front.rb +2 -2
  9. data/lib/asciidoctor/iso/isodoc.rng +254 -27
  10. data/lib/asciidoctor/iso/section.rb +1 -1
  11. data/lib/asciidoctor/iso/validate.rb +7 -7
  12. data/lib/asciidoctor/iso/validate_section.rb +1 -1
  13. data/lib/isodoc/iso/html/isodoc.css +0 -1
  14. data/lib/isodoc/iso/html/isodoc.scss +0 -1
  15. data/lib/isodoc/iso/html/style-human.css +0 -1
  16. data/lib/isodoc/iso/html/style-human.scss +0 -1
  17. data/lib/isodoc/iso/html/style-iso.css +0 -1
  18. data/lib/isodoc/iso/html/style-iso.scss +0 -1
  19. data/lib/isodoc/iso/i18n.rb +10 -9
  20. data/lib/isodoc/iso/iso.amendment.xsl +57 -17
  21. data/lib/isodoc/iso/iso.international-standard.xsl +57 -17
  22. data/lib/isodoc/iso/isosts_convert.rb +6 -2
  23. data/lib/isodoc/iso/presentation_xml_convert.rb +19 -9
  24. data/lib/isodoc/iso/sections.rb +2 -0
  25. data/lib/isodoc/iso/sts_convert.rb +5 -2
  26. data/lib/isodoc/iso/word_cleanup.rb +94 -0
  27. data/lib/isodoc/iso/word_convert.rb +12 -89
  28. data/lib/metanorma/iso/processor.rb +2 -2
  29. data/lib/metanorma/iso/version.rb +1 -1
  30. data/metanorma-iso.gemspec +4 -5
  31. data/spec/asciidoctor/base_spec.rb +543 -209
  32. data/spec/asciidoctor/blocks_spec.rb +22 -47
  33. data/spec/asciidoctor/cleanup_spec.rb +37 -20
  34. data/spec/asciidoctor/inline_spec.rb +10 -2
  35. data/spec/asciidoctor/refs_spec.rb +174 -88
  36. data/spec/asciidoctor/section_spec.rb +3 -3
  37. data/spec/isodoc/i18n_spec.rb +36 -22
  38. data/spec/isodoc/inline_spec.rb +6 -6
  39. data/spec/isodoc/section_spec.rb +4 -4
  40. data/spec/isodoc/table_spec.rb +6 -8
  41. data/spec/isodoc/terms_spec.rb +25 -25
  42. data/spec/isodoc/xref_spec.rb +1397 -1376
  43. data/spec/metanorma/processor_spec.rb +114 -15
  44. data/spec/spec_helper.rb +2 -1
  45. data/spec/vcr_cassettes/docrels.yml +427 -37
  46. data/spec/vcr_cassettes/sortrefs.yml +599 -0
  47. metadata +13 -24
@@ -8,6 +8,100 @@ RSpec.describe Metanorma::Iso::Processor do
8
8
  registry.register(Metanorma::Iso::Processor)
9
9
  processor = registry.find_processor(:iso)
10
10
 
11
+ inputxml = <<~INPUT
12
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
13
+ <bibdata type="standard">
14
+ <title language="en" format="text/plain" type="main">English</title>
15
+ <title language="en" format="text/plain" type="title-main">English</title>
16
+ <title language="fr" format="text/plain" type="main">French</title>
17
+ <title language="fr" format="text/plain" type="title-main">French</title>
18
+ <docidentifier type="ISO">ISO DIR 1</docidentifier><docidentifier type="iso-with-lang">ISO DIR 1(F)</docidentifier><docidentifier type="iso-reference">ISO DIR 1(F)</docidentifier>
19
+ <docnumber>1</docnumber>
20
+ <contributor>
21
+ <role type="author"/>
22
+ <organization>
23
+ <name>International Organization for Standardization</name>
24
+ <abbreviation>ISO</abbreviation>
25
+ </organization>
26
+ </contributor>
27
+ <contributor>
28
+ <role type="publisher"/>
29
+ <organization>
30
+ <name>International Organization for Standardization</name>
31
+ <abbreviation>ISO</abbreviation>
32
+ </organization>
33
+ </contributor>
34
+ <language>fr</language>
35
+ <script>Latn</script>
36
+ <status>
37
+ <stage abbreviation="IS">60</stage>
38
+ <substage>60</substage>
39
+ </status>
40
+ <copyright>
41
+ <from>2021</from>
42
+ <owner>
43
+ <organization>
44
+ <name>International Organization for Standardization</name>
45
+ <abbreviation>ISO</abbreviation>
46
+ </organization>
47
+ </owner>
48
+ </copyright>
49
+ <ext>
50
+ <doctype>directive</doctype>
51
+ <subdoctype>vocabulary</subdoctype>
52
+ <editorialgroup>
53
+ <technical-committee/>
54
+ <subcommittee/>
55
+ <workgroup/>
56
+ </editorialgroup>
57
+ <structuredidentifier>
58
+ <project-number>ISO 1</project-number>
59
+ </structuredidentifier>
60
+ <stagename>International standard</stagename>
61
+ </ext>
62
+ </bibdata>
63
+ <boilerplate>
64
+ <copyright-statement>
65
+ <clause>
66
+ <title>DOCUMENT PROT&#201;G&#201; PAR COPYRIGHT</title>
67
+ <p id="boilerplate-year">&#169; ISO 2021</p>
68
+
69
+ <p id="boilerplate-message">
70
+ Droits de reproduction r&#233;serv&#233;s. Sauf indication contraire, aucune partie de cette publication ne
71
+ peut &#234;tre reproduite ni utilis&#233;e sous quelque forme que ce soit et par aucun proc&#233;d&#233;, &#233;lectronique
72
+ ou m&#233;canique, y compris la photocopie, l&#8217;affichage sur l&#8217;internet ou sur un Intranet, sans
73
+ autorisation &#233;crite pr&#233;alable. Les demandes d&#8217;autorisation peuvent &#234;tre adress&#233;es &#224; l&#8217;ISO &#224;
74
+ l&#8217;adresse ci-apr&#232;s ou au comit&#233; membre de l&#8217;ISO dans le pays du demandeur.
75
+ </p>
76
+
77
+ <p id="boilerplate-address" align="left">
78
+ ISO copyright office<br/>
79
+ Ch. de Blandonnet 8 &#8226; CP 401<br/>
80
+ CH-1214 Vernier, Geneva, Switzerland<br/>
81
+ Tel.&#160;&#160;+ 41 22 749 01 11<br/>
82
+ Fax&#160;&#160;+ 41 22 749 09 47<br/>
83
+ Email: copyright@iso.org<br/>
84
+ Website: www.iso.org
85
+ </p>
86
+ <p id="boilerplate-place">
87
+ Publi&#233; en Suisse
88
+ </p>
89
+ </clause>
90
+ </copyright-statement>
91
+
92
+
93
+ </boilerplate>
94
+ <sections>
95
+ <terms id="H" obligation="normative"><title>1&#xA0; Terms, Definitions, Symbols and Abbreviated Terms</title>
96
+ <term id="J">
97
+ <name>1.1</name>
98
+ <preferred>Term2</preferred>
99
+ </term>
100
+ </terms>
101
+ </sections>
102
+ </iso-standard>
103
+ INPUT
104
+
11
105
  it "registers against metanorma" do
12
106
  expect(processor).not_to be nil
13
107
  end
@@ -23,36 +117,30 @@ RSpec.describe Metanorma::Iso::Processor do
23
117
  end
24
118
 
25
119
  it "generates IsoDoc XML from a blank document" do
26
- expect(xmlpp(processor.input_to_isodoc(<<~"INPUT", nil))).to be_equivalent_to xmlpp(<<~"OUTPUT")
120
+ input = <<~INPUT
27
121
  #{ASCIIDOC_BLANK_HDR}
28
122
  INPUT
123
+ output = <<~OUTPUT
29
124
  #{BLANK_HDR}
30
125
  <sections/>
31
126
  </iso-standard>
32
127
  OUTPUT
128
+ expect(xmlpp(processor.input_to_isodoc(input, nil)))
129
+ .to be_equivalent_to xmlpp(output)
33
130
  end
34
131
 
35
- it "generates HTML from IsoDoc XML" do
132
+ it "generates HTML from Metanorma XML" do
36
133
  FileUtils.rm_f "test.xml"
37
- processor.output(<<~"INPUT", "test.xml", "test.html", :html)
38
- <iso-standard xmlns="http://riboseinc.com/isoxml">
39
- <sections>
40
- <terms id="H" obligation="normative"><title>1&#xA0; Terms, Definitions, Symbols and Abbreviated Terms</title>
41
- <term id="J">
42
- <name>1.1</name>
43
- <preferred>Term2</preferred>
44
- </term>
45
- </terms>
46
- </sections>
47
- </iso-standard>
48
- INPUT
134
+ FileUtils.rm_f "test.html"
135
+ processor.output(inputxml, "test.xml", "test.html", :html)
49
136
  expect(xmlpp(File.read("test.html", encoding: "utf-8")
50
137
  .gsub(%r{^.*<main}m, "<main")
51
138
  .gsub(%r{</main>.*}m, "</main>")))
52
139
  .to be_equivalent_to xmlpp(<<~"OUTPUT")
53
140
  <main class="main-section">
54
141
  <button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
55
- <p class="zzSTDTitle1"></p>
142
+ <div class='authority'> </div>
143
+ <p class='zzSTDTitle1'>French</p>
56
144
  <div id="H"><h1 id="toc0">1&#xA0; Terms, Definitions, Symbols and Abbreviated Terms</h1>
57
145
  <h2 class="TermNum" id="J">1.1</h2>
58
146
  <p class="Terms" style="text-align:left;">Term2</p>
@@ -60,4 +148,15 @@ RSpec.describe Metanorma::Iso::Processor do
60
148
  </main>
61
149
  OUTPUT
62
150
  end
151
+
152
+ it "generates STS from Metanorma XML" do
153
+ FileUtils.rm_f "test.xml"
154
+ FileUtils.rm_f "test.sts.xml"
155
+ FileUtils.rm_f "test.iso.sts.xml"
156
+ File.open("test.xml", "w") { |f| f.write inputxml }
157
+ processor.output(inputxml, "test.xml", "test.sts.xml", :sts)
158
+ processor.output(inputxml, "test.xml", "test.iso.sts.xml", :isosts)
159
+ expect(File.exist?("test.sts.xml")).to be true
160
+ expect(File.exist?("test.iso.sts.xml")).to be true
161
+ end
63
162
  end
data/spec/spec_helper.rb CHANGED
@@ -58,7 +58,8 @@ def xmlpp(xml)
58
58
  s = ""
59
59
  f = REXML::Formatters::Pretty.new(2)
60
60
  f.compact = true
61
- f.write(REXML::Document.new(xml), s)
61
+ f.write(REXML::Document.new(xml
62
+ .gsub(%r{<fetched>20[0-9-]+</fetched>}, "<fetched/>")), s)
62
63
  s
63
64
  end
64
65