metanorma-iec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/bin/rspec +18 -0
  4. data/lib/asciidoctor/iec/biblio.rng +949 -0
  5. data/lib/asciidoctor/iec/converter.rb +68 -0
  6. data/lib/asciidoctor/iec/iec_intro_en.xml +15 -0
  7. data/lib/asciidoctor/iec/iec_intro_fr.xml +15 -0
  8. data/lib/asciidoctor/iec/isodoc.rng +1132 -0
  9. data/lib/asciidoctor/iec/isostandard.rng +789 -0
  10. data/lib/asciidoctor/iec/reqt.rng +162 -0
  11. data/lib/isodoc/iec/base_convert.rb +69 -0
  12. data/lib/isodoc/iec/html/header.html +160 -0
  13. data/lib/isodoc/iec/html/html_iec_intro.html +34 -0
  14. data/lib/isodoc/iec/html/html_iec_titlepage.html +62 -0
  15. data/lib/isodoc/iec/html/htmlstyle.scss +840 -0
  16. data/lib/isodoc/iec/html/isodoc.scss +785 -0
  17. data/lib/isodoc/iec/html/scripts.html +176 -0
  18. data/lib/isodoc/iec/html/word_iec_intro.html +72 -0
  19. data/lib/isodoc/iec/html/word_iec_titlepage.html +92 -0
  20. data/lib/isodoc/iec/html/wordstyle.scss +1849 -0
  21. data/lib/isodoc/iec/html_convert.rb +33 -0
  22. data/lib/isodoc/iec/i18n-en.yaml +3 -0
  23. data/lib/isodoc/iec/i18n-fr.yaml +3 -0
  24. data/lib/isodoc/iec/i18n-zh-Hans.yaml +3 -0
  25. data/lib/isodoc/iec/metadata.rb +20 -0
  26. data/lib/isodoc/iec/word_convert.rb +165 -0
  27. data/lib/metanorma-iec.rb +12 -0
  28. data/lib/metanorma/iec.rb +8 -0
  29. data/lib/metanorma/iec/processor.rb +40 -0
  30. data/lib/metanorma/iec/version.rb +6 -0
  31. data/metanorma-iec.gemspec +47 -0
  32. data/spec/asciidoctor-iec/base_spec.rb +609 -0
  33. data/spec/asciidoctor-iec/blocks_spec.rb +467 -0
  34. data/spec/asciidoctor-iec/cleanup_spec.rb +766 -0
  35. data/spec/asciidoctor-iec/inline_spec.rb +162 -0
  36. data/spec/asciidoctor-iec/lists_spec.rb +190 -0
  37. data/spec/asciidoctor-iec/macros_spec.rb +21 -0
  38. data/spec/asciidoctor-iec/refs_spec.rb +268 -0
  39. data/spec/asciidoctor-iec/section_spec.rb +341 -0
  40. data/spec/asciidoctor-iec/table_spec.rb +307 -0
  41. data/spec/asciidoctor-iec/validate_spec.rb +132 -0
  42. data/spec/examples/rice.adoc +723 -0
  43. data/spec/examples/rice.doc +19162 -0
  44. data/spec/examples/rice.html +1787 -0
  45. data/spec/examples/rice.xml +1951 -0
  46. data/spec/isodoc/i18n_spec.rb +642 -0
  47. data/spec/isodoc/inline_spec.rb +265 -0
  48. data/spec/isodoc/iso_spec.rb +319 -0
  49. data/spec/isodoc/metadata_spec.rb +153 -0
  50. data/spec/isodoc/postproc_spec.rb +569 -0
  51. data/spec/isodoc/section_spec.rb +686 -0
  52. data/spec/isodoc/terms_spec.rb +206 -0
  53. data/spec/isodoc/xref_spec.rb +1323 -0
  54. data/spec/metanorma/processor_spec.rb +88 -0
  55. data/spec/spec_helper.rb +253 -0
  56. metadata +325 -0
@@ -0,0 +1,265 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe IsoDoc do
4
+ it "processes inline formatting" do
5
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <preface><foreword>
8
+ <p>
9
+ <em>A</em> <strong>B</strong> <sup>C</sup> <sub>D</sub> <tt>E</tt>
10
+ <strike>F</strike> <smallcap>G</smallcap> <br/> <hr/>
11
+ <bookmark id="H"/> <pagebreak/>
12
+ </p>
13
+ </foreword></preface>
14
+ <sections>
15
+ </iso-standard>
16
+ INPUT
17
+ #{HTML_HDR}
18
+ <div>
19
+ <h1 class="ForewordTitle">FOREWORD</h1>
20
+ <div class="boilerplate_legal"/>
21
+ <p>
22
+ <i>A</i> <b>B</b> <sup>C</sup> <sub>D</sub> <tt>E</tt>
23
+ <s>F</s> <span style="font-variant:small-caps;">G</span> <br/> <hr/>
24
+ <a id="H"/> <br/>
25
+ </p>
26
+ </div>
27
+ #{IEC_TITLE}
28
+ </div>
29
+ </body>
30
+ </html>
31
+ OUTPUT
32
+ end
33
+
34
+ it "processes links" do
35
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
36
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
37
+ <preface><foreword>
38
+ <p>
39
+ <link target="http://example.com"/>
40
+ <link target="http://example.com">example</link>
41
+ <link target="mailto:fred@example.com"/>
42
+ <link target="mailto:fred@example.com">mailto:fred@example.com</link>
43
+ </p>
44
+ </foreword></preface>
45
+ <sections>
46
+ </iso-standard>
47
+ INPUT
48
+ #{HTML_HDR}
49
+ <div>
50
+ <h1 class="ForewordTitle">FOREWORD</h1>
51
+ <div class="boilerplate_legal"/>
52
+ <p>
53
+ <a href="http://example.com">http://example.com</a>
54
+ <a href="http://example.com">example</a>
55
+ <a href="mailto:fred@example.com">fred@example.com</a>
56
+ <a href="mailto:fred@example.com">mailto:fred@example.com</a>
57
+ </p>
58
+ </div>
59
+ #{IEC_TITLE}
60
+ </div>
61
+ </body>
62
+ </html>
63
+ OUTPUT
64
+ end
65
+
66
+ it "processes unrecognised markup" do
67
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
68
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
69
+ <preface><foreword>
70
+ <p>
71
+ <barry fred="http://example.com">example</barry>
72
+ </p>
73
+ </foreword></preface>
74
+ <sections>
75
+ </iso-standard>
76
+ INPUT
77
+ #{HTML_HDR}
78
+ <div>
79
+ <h1 class="ForewordTitle">FOREWORD</h1>
80
+ <div class="boilerplate_legal"/>
81
+ <p>
82
+ <para><b role="strong">&lt;barry fred="http://example.com"&gt;example&lt;/barry&gt;</b></para>
83
+ </p>
84
+ </div>
85
+ #{IEC_TITLE}
86
+ </div>
87
+ </body>
88
+ </html>
89
+ OUTPUT
90
+ end
91
+
92
+ it "processes AsciiMath and MathML" do
93
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
94
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
95
+ <preface><foreword>
96
+ <p>
97
+ <stem type="AsciiMath">A</stem>
98
+ <stem type="MathML"><m:math><m:row>X</m:row></m:math></stem>
99
+ <stem type="None">Latex?</stem>
100
+ </p>
101
+ </foreword></preface>
102
+ <sections>
103
+ </iso-standard>
104
+ INPUT
105
+ #{HTML_HDR}
106
+ <div>
107
+ <h1 class="ForewordTitle">FOREWORD</h1>
108
+ <div class="boilerplate_legal"/>
109
+ <p>
110
+ <span class="stem">(#(A)#)</span>
111
+ <span class="stem"><m:math>
112
+ <m:row>X</m:row>
113
+ </m:math></span>
114
+ <span class="stem">Latex?</span>
115
+ </p>
116
+ </div>
117
+ #{IEC_TITLE}
118
+ </div>
119
+ </body>
120
+ </html>
121
+ OUTPUT
122
+ end
123
+
124
+ it "overrides AsciiMath delimiters" do
125
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
126
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
127
+ <preface><foreword>
128
+ <p>
129
+ <stem type="AsciiMath">A</stem>
130
+ (#((Hello))#)
131
+ </p>
132
+ </foreword></preface>
133
+ <sections>
134
+ </iso-standard>
135
+ INPUT
136
+ #{HTML_HDR}
137
+ <div>
138
+ <h1 class="ForewordTitle">FOREWORD</h1>
139
+ <div class="boilerplate_legal"/>
140
+ <p>
141
+ <span class="stem">(#(((A)#)))</span>
142
+ (#((Hello))#)
143
+ </p>
144
+ </div>
145
+ #{IEC_TITLE}
146
+ </div>
147
+ </body>
148
+ </html>
149
+ OUTPUT
150
+ end
151
+
152
+ it "processes eref types" do
153
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
154
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
155
+ <preface><foreword>
156
+ <p>
157
+ <eref type="footnote" bibitemid="ISO712" citeas="ISO 712">A</stem>
158
+ <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</stem>
159
+ </p>
160
+ </foreword></preface>
161
+ <bibliography><references id="_normative_references" obligation="informative"><title>Normative References</title>
162
+ <bibitem id="ISO712" type="standard">
163
+ <title format="text/plain">Cereals and cereal products</title>
164
+ <docidentifier>ISO 712</docidentifier>
165
+ <contributor>
166
+ <role type="publisher"/>
167
+ <organization>
168
+ <abbreviation>ISO</abbreviation>
169
+ </organization>
170
+ </contributor>
171
+ </bibitem>
172
+ </references>
173
+ </bibliography>
174
+ </iso-standard>
175
+ INPUT
176
+ #{HTML_HDR}
177
+ <div>
178
+ <h1 class="ForewordTitle">FOREWORD</h1>
179
+ <div class="boilerplate_legal"/>
180
+ <p>
181
+ <sup><a href="#ISO712">A</a></sup>
182
+ <a href="#ISO712">A</a>
183
+ </p>
184
+ </div>
185
+ #{IEC_TITLE}
186
+ <div>
187
+ <h1>1&#160; Normative references</h1>
188
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
189
+ <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
190
+ </div>
191
+ </div>
192
+ </body>
193
+ </html>
194
+ OUTPUT
195
+ end
196
+
197
+ it "processes eref content" do
198
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
199
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
200
+ <preface><foreword>
201
+ <p>
202
+ <eref type="inline" bibitemid="IEV" citeas="IEV"><locality type="clause"><referenceFrom>1-2-3</referenceFrom></locality></eref>
203
+ <eref type="inline" bibitemid="ISO712" citeas="ISO 712"/>
204
+ <eref type="inline" bibitemid="ISO712"/>
205
+ <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
206
+ <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref>
207
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
208
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="list"><referenceFrom>a</referenceFrom></locality></eref>
209
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
210
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1.5</referenceFrom></locality></eref>
211
+ <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality>A</eref>
212
+ <eref type="inline" bibitemid="ISO712"><locality type="whole"></locality></eref>
213
+ <eref type="inline" bibitemid="ISO712"><locality type="locality:prelude"><referenceFrom>7</referenceFrom></locality></eref>
214
+ <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
215
+ </p>
216
+ </foreword></preface>
217
+ <bibliography><references id="_normative_references" obligation="informative"><title>Normative References</title>
218
+ <bibitem id="ISO712" type="standard">
219
+ <title format="text/plain">Cereals and cereal products</title>
220
+ <docidentifier>ISO 712</docidentifier>
221
+ <contributor>
222
+ <role type="publisher"/>
223
+ <organization>
224
+ <abbreviation>ISO</abbreviation>
225
+ </organization>
226
+ </contributor>
227
+ </bibitem>
228
+ </references>
229
+ </bibliography>
230
+ </iso-standard>
231
+ INPUT
232
+ #{HTML_HDR}
233
+ <div>
234
+ <h1 class="ForewordTitle">FOREWORD</h1>
235
+ <div class="boilerplate_legal"/>
236
+ <p>
237
+ <a href="#IEV">IEV, 1-2-3</a>
238
+ <a href="#ISO712">ISO 712</a>
239
+ <a href="#ISO712">ISO 712</a>
240
+ <a href="#ISO712">ISO 712, Table 1</a>
241
+ <a href="#ISO712">ISO 712, Table 1&#8211;1</a>
242
+ <a href="#ISO712">ISO 712, Clause 1, Table 1</a>
243
+ <a href="#ISO712">ISO 712, Clause 1 a)</a>
244
+ <a href="#ISO712">ISO 712, Clause 1</a>
245
+ <a href="#ISO712">ISO 712, 1.5</a>
246
+ <a href="#ISO712">A</a>
247
+ <a href="#ISO712">ISO 712, </a>
248
+ <a href="#ISO712">ISO 712, Prelude 7</a>
249
+ <a href="#ISO712">A</a>
250
+ </p>
251
+ </div>
252
+ #{IEC_TITLE}
253
+ <div>
254
+ <h1>1&#160; Normative references</h1>
255
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
256
+ <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
257
+ </div>
258
+ </div>
259
+ </body>
260
+ </html>
261
+ OUTPUT
262
+ end
263
+
264
+
265
+ end
@@ -0,0 +1,319 @@
1
+ require "spec_helper"
2
+ require "fileutils"
3
+
4
+ RSpec.describe IsoDoc::Iec do
5
+ FileUtils.rm_f "test.html"
6
+ it "processes isodoc as ISO: HTML output" do
7
+ IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", false)
8
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
9
+ <preface><foreword>
10
+ <note>
11
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
12
+ </note>
13
+ </foreword></preface>
14
+ </iso-standard>
15
+ INPUT
16
+ html = File.read("test.html", encoding: "utf-8")
17
+ expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
18
+ expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Cambria", serif;]m)
19
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
20
+ end
21
+
22
+ it "processes isodoc as ISO: alt HTML output" do
23
+ FileUtils.rm_f "test.html"
24
+ IsoDoc::Iec::HtmlConvert.new({alt: true}).convert("test", <<~"INPUT", false)
25
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
26
+ <preface><foreword>
27
+ <note>
28
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
29
+ </note>
30
+ </foreword></preface>
31
+ </iso-standard>
32
+ INPUT
33
+ html = File.read("test.html", encoding: "utf-8")
34
+ expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
35
+ expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
36
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Lato", sans-serif;]m)
37
+ end
38
+
39
+ it "processes isodoc as ISO: Chinese HTML output" do
40
+ FileUtils.rm_f "test.html"
41
+ IsoDoc::Iec::HtmlConvert.new({script: "Hans"}).convert("test", <<~"INPUT", false)
42
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
43
+ <preface><foreword>
44
+ <note>
45
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
46
+ </note>
47
+ </foreword></preface>
48
+ </iso-standard>
49
+ INPUT
50
+ html = File.read("test.html", encoding: "utf-8")
51
+ expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
52
+ expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "SimSun", serif;]m)
53
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
54
+ end
55
+
56
+ it "processes isodoc as ISO: user nominated fonts" do
57
+ FileUtils.rm_f "test.html"
58
+ IsoDoc::Iec::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).convert("test", <<~"INPUT", false)
59
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
60
+ <preface><foreword>
61
+ <note>
62
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
63
+ </note>
64
+ </foreword></preface>
65
+ </iso-standard>
66
+ INPUT
67
+ html = File.read("test.html", encoding: "utf-8")
68
+ expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: Andale Mono;]m)
69
+ expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
70
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
71
+ end
72
+
73
+ it "processes isodoc as ISO: Word output" do
74
+ FileUtils.rm_f "test.doc"
75
+ IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", false)
76
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
77
+ <preface><foreword>
78
+ <note>
79
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
80
+ </note>
81
+ </foreword></preface>
82
+ </iso-standard>
83
+ INPUT
84
+ html = File.read("test.doc", encoding: "utf-8")
85
+ expect(html).to match(%r[\.Sourcecode[^{]+\{[^{]+font-family: "Courier New",monospace;]m)
86
+ expect(html).to match(%r[Quote[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
87
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Arial",sans-serif;]m)
88
+ end
89
+
90
+ it "does not include IEV in references" do
91
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
92
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
93
+ <preface><foreword>
94
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
95
+ <eref bibitemid="IEV"/>
96
+ <eref bibitemid="ISO20483"/>
97
+ </p>
98
+ </foreword></preface>
99
+ <bibliography><references id="_normative_references" obligation="informative"><title>Normative References</title>
100
+ <bibitem type="international-standard" id="IEV">
101
+ <title format="text/plain" language="en" script="Latn">Electropedia:
102
+ The World's Online Electrotechnical Vocabulary</title>
103
+ <uri type="src">http://www.electropedia.org</uri>
104
+ <docidentifier>IEV</docidentifier>
105
+ <contributor>
106
+ <role type="publisher"/>
107
+ <organization>
108
+ <name>International Electrotechnical Commission</name>
109
+ <abbreviation>IEC</abbreviation>
110
+ <uri>www.iec.ch</uri>
111
+ </organization>
112
+ </contributor>
113
+ <language>en</language> <language>fr</language>
114
+ <script>Latn</script>
115
+ <copyright>
116
+ <owner>
117
+ <organization>
118
+ <name>International Electrotechnical Commission</name>
119
+ <abbreviation>IEC</abbreviation>
120
+ <uri>www.iec.ch</uri>
121
+ </organization>
122
+ </owner>
123
+ </copyright>
124
+ <relation type="updates">
125
+ <bibitem>
126
+ <formattedref>IEC 60050</formattedref>
127
+ </bibitem>
128
+ </relation>
129
+ </bibitem>
130
+ <bibitem id="ISO20483" type="standard">
131
+ <title format="text/plain">Cereals and pulses</title>
132
+ <docidentifier>ISO 20483</docidentifier>
133
+ <date type="published"><from>2013</from><to>2014</to></date>
134
+ <contributor>
135
+ <role type="publisher"/>
136
+ <organization>
137
+ <name>International Organization for Standardization</name>
138
+ </organization>
139
+ </contributor>
140
+ </bibitem>
141
+ </references>
142
+ </bibliography>
143
+ </iso-standard>
144
+ INPUT
145
+ #{HTML_HDR}
146
+ <div>
147
+ <h1 class="ForewordTitle">FOREWORD</h1>
148
+ <div class="boilerplate_legal"/>
149
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
150
+ <a href="#IEV">IEV</a>
151
+ <a href="#ISO20483">ISO 20483</a>
152
+ </p>
153
+ </div>
154
+ #{IEC_TITLE}
155
+ <div>
156
+ <h1>1&#160; Normative references</h1>
157
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
158
+ <p id="ISO20483" class="NormRef">ISO 20483, <i> Cereals and pulses</i></p>
159
+ </div>
160
+ </div>
161
+ </body>
162
+ </html>
163
+
164
+ OUTPUT
165
+ end
166
+
167
+ it "processes examples" do
168
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
169
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
170
+ <preface><foreword>
171
+ <example id="samplecode">
172
+ <p>Hello</p>
173
+ </example>
174
+ </foreword></preface>
175
+ </iso-standard>
176
+ INPUT
177
+ #{HTML_HDR}
178
+ <div>
179
+ <h1 class="ForewordTitle">FOREWORD</h1>
180
+ <div class="boilerplate_legal"/>
181
+ <div id="samplecode" class="example">
182
+ <p><span class="example_label">EXAMPLE</span>&#160; Hello</p>
183
+ </div>
184
+ </div>
185
+ #{IEC_TITLE}
186
+ </div>
187
+ </body>
188
+ </html>
189
+ OUTPUT
190
+ end
191
+
192
+
193
+ it "processes sequences of examples" do
194
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
195
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
196
+ <preface><foreword>
197
+ <example id="samplecode">
198
+ <p>Hello</p>
199
+ </example>
200
+ <example id="samplecode2">
201
+ <p>Hello</p>
202
+ </example>
203
+ </foreword></preface>
204
+ </iso-standard>
205
+ INPUT
206
+ #{HTML_HDR}
207
+ <div>
208
+ <h1 class="ForewordTitle">FOREWORD</h1>
209
+ <div class="boilerplate_legal"/>
210
+ <div id="samplecode" class="example">
211
+ <p><span class="example_label">EXAMPLE 1</span>&#160; Hello</p>
212
+ </div>
213
+ <div id="samplecode2" class="example">
214
+ <p><span class="example_label">EXAMPLE 2</span>&#160; Hello</p>
215
+ </div>
216
+ </div>
217
+ #{IEC_TITLE}
218
+ </div>
219
+ </body>
220
+ </html>
221
+ OUTPUT
222
+ end
223
+
224
+ it "processes examples (Word)" do
225
+ expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body")).to be_equivalent_to <<~"OUTPUT"
226
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
227
+ <preface><foreword>
228
+ <example id="samplecode">
229
+ <p>Hello</p>
230
+ </example>
231
+ </foreword></preface>
232
+ </iso-standard>
233
+ INPUT
234
+ <body lang="EN-US" link="blue" vlink="#954F72">
235
+ <div class="WordSection1">
236
+ <p>&#160;</p>
237
+ </div>
238
+ <p>
239
+ <br clear="all" class="section"/>
240
+ </p>
241
+ <div class="WordSection2">
242
+ <p>
243
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
244
+ </p>
245
+ #{IEC_TITLE}
246
+ <div>
247
+ <h1 class="ForewordTitle">FOREWORD</h1>
248
+ <div class="boilerplate_legal"/>
249
+ <div id="samplecode" class="example">
250
+ <p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
251
+ </div>
252
+ </div>
253
+ <p>&#160;</p>
254
+ </div>
255
+ <p>
256
+ <br clear="all" class="section"/>
257
+ </p>
258
+ <div class="WordSection3">
259
+ #{IEC_TITLE}
260
+ </div>
261
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
262
+ <div class="colophon"/>
263
+ </body>
264
+ </html>
265
+ OUTPUT
266
+ end
267
+
268
+
269
+ it "processes sequences of examples (Word)" do
270
+ expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body")).to be_equivalent_to <<~"OUTPUT"
271
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
272
+ <preface><foreword>
273
+ <example id="samplecode">
274
+ <p>Hello</p>
275
+ </example>
276
+ <example id="samplecode2">
277
+ <p>Hello</p>
278
+ </example>
279
+ </foreword></preface>
280
+ </iso-standard>
281
+ INPUT
282
+ <body lang="EN-US" link="blue" vlink="#954F72">
283
+ <div class="WordSection1">
284
+ <p>&#160;</p>
285
+ </div>
286
+ <p>
287
+ <br clear="all" class="section"/>
288
+ </p>
289
+ <div class="WordSection2">
290
+ <p>
291
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
292
+ </p>
293
+ #{IEC_TITLE}
294
+ <div>
295
+ <h1 class="ForewordTitle">FOREWORD</h1>
296
+ <div class="boilerplate_legal"/>
297
+ <div id="samplecode" class="example">
298
+ <p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
299
+ </div>
300
+ <div id="samplecode2" class="example">
301
+ <p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
302
+ </div>
303
+ </div>
304
+ <p>&#160;</p>
305
+ </div>
306
+ <p>
307
+ <br clear="all" class="section"/>
308
+ </p>
309
+ <div class="WordSection3">
310
+ #{IEC_TITLE}
311
+ </div>
312
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
313
+ <div class="colophon"/>
314
+ </body>
315
+ </html>
316
+ OUTPUT
317
+ end
318
+
319
+ end