metanorma-bsi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.hound.yml +3 -0
- data/.rubocop.yml +14 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/LICENSE +25 -0
- data/README.adoc +199 -0
- data/Rakefile +8 -0
- data/bin/rspec +18 -0
- data/lib/asciidoctor/bsi/basicdoc.rng +1131 -0
- data/lib/asciidoctor/bsi/biblio.rng +1235 -0
- data/lib/asciidoctor/bsi/bsi.rng +120 -0
- data/lib/asciidoctor/bsi/bsi_intro_en.xml +105 -0
- data/lib/asciidoctor/bsi/cleanup.rb +78 -0
- data/lib/asciidoctor/bsi/cleanup_ref.rb +183 -0
- data/lib/asciidoctor/bsi/converter.rb +83 -0
- data/lib/asciidoctor/bsi/front.rb +67 -0
- data/lib/asciidoctor/bsi/isodoc.rng +1870 -0
- data/lib/asciidoctor/bsi/isostandard.rng +477 -0
- data/lib/asciidoctor/bsi/reqt.rng +194 -0
- data/lib/asciidoctor/bsi/validate.rb +224 -0
- data/lib/asciidoctor/bsi/validate_list.rb +72 -0
- data/lib/asciidoctor/bsi/validate_requirement.rb +163 -0
- data/lib/isodoc/bsi/base_convert.rb +91 -0
- data/lib/isodoc/bsi/bsi.international-standard.xsl +6540 -0
- data/lib/isodoc/bsi/html/html_bsi_intro.html +8 -0
- data/lib/isodoc/bsi/html/html_bsi_titlepage.html +50 -0
- data/lib/isodoc/bsi/html/htmlstyle.css +968 -0
- data/lib/isodoc/bsi/html/htmlstyle.scss +699 -0
- data/lib/isodoc/bsi/html_convert.rb +56 -0
- data/lib/isodoc/bsi/i18n-en.yaml +56 -0
- data/lib/isodoc/bsi/i18n.rb +15 -0
- data/lib/isodoc/bsi/init.rb +24 -0
- data/lib/isodoc/bsi/metadata.rb +33 -0
- data/lib/isodoc/bsi/pdf_convert.rb +17 -0
- data/lib/isodoc/bsi/presentation_xml_convert.rb +72 -0
- data/lib/isodoc/bsi/sts_convert.rb +30 -0
- data/lib/isodoc/bsi/xref.rb +134 -0
- data/lib/metanorma-bsi.rb +15 -0
- data/lib/metanorma/bsi.rb +6 -0
- data/lib/metanorma/bsi/processor.rb +51 -0
- data/lib/metanorma/bsi/version.rb +6 -0
- data/metanorma-bsi.gemspec +47 -0
- data/spec/asciidoctor/base_spec.rb +778 -0
- data/spec/asciidoctor/blocks_spec.rb +553 -0
- data/spec/asciidoctor/cleanup_spec.rb +547 -0
- data/spec/asciidoctor/inline_spec.rb +176 -0
- data/spec/asciidoctor/lists_spec.rb +194 -0
- data/spec/asciidoctor/refs_spec.rb +318 -0
- data/spec/asciidoctor/section_spec.rb +382 -0
- data/spec/asciidoctor/validate_spec.rb +858 -0
- data/spec/assets/header.html +7 -0
- data/spec/assets/html.css +2 -0
- data/spec/assets/iso.xml +71 -0
- data/spec/assets/rice_image1.png +0 -0
- data/spec/assets/word.css +2 -0
- data/spec/assets/wordintro.html +4 -0
- data/spec/assets/xref_error.adoc +7 -0
- data/spec/isodoc/blocks_spec.rb +259 -0
- data/spec/isodoc/i18n_spec.rb +442 -0
- data/spec/isodoc/inline_spec.rb +287 -0
- data/spec/isodoc/iso_spec.rb +116 -0
- data/spec/isodoc/metadata_spec.rb +262 -0
- data/spec/isodoc/postproc_spec.rb +137 -0
- data/spec/isodoc/ref_spec.rb +376 -0
- data/spec/isodoc/section_spec.rb +467 -0
- data/spec/isodoc/terms_spec.rb +246 -0
- data/spec/isodoc/xref_spec.rb +1730 -0
- data/spec/metanorma/processor_spec.rb +76 -0
- data/spec/spec_helper.rb +291 -0
- data/spec/vcr_cassettes/iso-639.yml +182 -0
- data/spec/vcr_cassettes/isobib_get_639_1967.yml +136 -0
- data/spec/vcr_cassettes/multistandard.yml +352 -0
- metadata +343 -0
@@ -0,0 +1,287 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe IsoDoc do
|
4
|
+
it "processes inline formatting" do
|
5
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"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_TITLE1}
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
OUTPUT
|
32
|
+
end
|
33
|
+
|
34
|
+
it "processes links" do
|
35
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"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_TITLE1}
|
60
|
+
</div>
|
61
|
+
</body>
|
62
|
+
</html>
|
63
|
+
OUTPUT
|
64
|
+
end
|
65
|
+
|
66
|
+
it "processes unrecognised markup" do
|
67
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"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"><barry fred="http://example.com">example</barry></b></para>
|
83
|
+
</p>
|
84
|
+
</div>
|
85
|
+
#{IEC_TITLE1}
|
86
|
+
</div>
|
87
|
+
</body>
|
88
|
+
</html>
|
89
|
+
OUTPUT
|
90
|
+
end
|
91
|
+
|
92
|
+
it "processes AsciiMath and MathML" do
|
93
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true).sub(/<html/, "<html xmlns:m='m'"))).to be_equivalent_to xmlpp(<<~"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.sub(/<html/, "<html xmlns:m='m'")}
|
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_TITLE1}
|
118
|
+
</div>
|
119
|
+
</body>
|
120
|
+
</html>
|
121
|
+
OUTPUT
|
122
|
+
end
|
123
|
+
|
124
|
+
it "overrides AsciiMath delimiters" do
|
125
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"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_TITLE1}
|
146
|
+
</div>
|
147
|
+
</body>
|
148
|
+
</html>
|
149
|
+
OUTPUT
|
150
|
+
end
|
151
|
+
|
152
|
+
it "processes eref content" do
|
153
|
+
expect(xmlpp(IsoDoc::BSI::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
154
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
155
|
+
<preface><foreword>
|
156
|
+
<p>
|
157
|
+
<eref type="inline" bibitemid="IEV" citeas="IEV"><locality type="clause"><referenceFrom>1-2-3</referenceFrom></locality></eref>
|
158
|
+
<eref type="inline" bibitemid="ISO712" citeas="ISO 712"/>
|
159
|
+
<eref type="inline" bibitemid="ISO712"/>
|
160
|
+
<eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
|
161
|
+
<eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref>
|
162
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
|
163
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="list"><referenceFrom>a</referenceFrom></locality></eref>
|
164
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
|
165
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1.5</referenceFrom></locality></eref>
|
166
|
+
<eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality>A</eref>
|
167
|
+
<eref type="inline" bibitemid="ISO712"><locality type="whole"></locality></eref>
|
168
|
+
<eref type="inline" bibitemid="ISO712"><locality type="locality:prelude"><referenceFrom>7</referenceFrom></locality></eref>
|
169
|
+
<eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
|
170
|
+
</p>
|
171
|
+
</foreword></preface>
|
172
|
+
<bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
|
173
|
+
<bibitem id="ISO712" type="standard">
|
174
|
+
<title format="text/plain">Cereals and cereal products</title>
|
175
|
+
<docidentifier>ISO 712</docidentifier>
|
176
|
+
<contributor>
|
177
|
+
<role type="publisher"/>
|
178
|
+
<organization>
|
179
|
+
<abbreviation>ISO</abbreviation>
|
180
|
+
</organization>
|
181
|
+
</contributor>
|
182
|
+
</bibitem>
|
183
|
+
</references>
|
184
|
+
</bibliography>
|
185
|
+
</iso-standard>
|
186
|
+
INPUT
|
187
|
+
<?xml version='1.0'?>
|
188
|
+
<iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
|
189
|
+
<preface>
|
190
|
+
<foreword>
|
191
|
+
<p>
|
192
|
+
<eref type='inline' bibitemid='IEV' citeas='IEV'>
|
193
|
+
<locality type='clause'>
|
194
|
+
<referenceFrom>1-2-3</referenceFrom>
|
195
|
+
</locality>
|
196
|
+
IEV,<strong> 1-2-3</strong>
|
197
|
+
</eref>
|
198
|
+
<eref type='inline' bibitemid='ISO712' citeas='ISO 712'>ISO 712</eref>
|
199
|
+
<eref type='inline' bibitemid='ISO712'>ISO 712</eref>
|
200
|
+
<eref type='inline' bibitemid='ISO712'>
|
201
|
+
<locality type='table'>
|
202
|
+
<referenceFrom>1</referenceFrom>
|
203
|
+
</locality>
|
204
|
+
ISO 712, Table 1
|
205
|
+
</eref>
|
206
|
+
<eref type='inline' bibitemid='ISO712'>
|
207
|
+
<locality type='table'>
|
208
|
+
<referenceFrom>1</referenceFrom>
|
209
|
+
<referenceTo>1</referenceTo>
|
210
|
+
</locality>
|
211
|
+
ISO 712, Table 1–1
|
212
|
+
</eref>
|
213
|
+
<eref type='inline' bibitemid='ISO712'>
|
214
|
+
<locality type='clause'>
|
215
|
+
<referenceFrom>1</referenceFrom>
|
216
|
+
</locality>
|
217
|
+
<locality type='table'>
|
218
|
+
<referenceFrom>1</referenceFrom>
|
219
|
+
</locality>
|
220
|
+
ISO 712, Clause <strong>1</strong>, Table 1
|
221
|
+
</eref>
|
222
|
+
<eref type='inline' bibitemid='ISO712'>
|
223
|
+
<locality type='clause'>
|
224
|
+
<referenceFrom>1</referenceFrom>
|
225
|
+
</locality>
|
226
|
+
<locality type='list'>
|
227
|
+
<referenceFrom>a</referenceFrom>
|
228
|
+
</locality>
|
229
|
+
ISO 712, Clause <strong>1</strong>a)
|
230
|
+
</eref>
|
231
|
+
<eref type='inline' bibitemid='ISO712'>
|
232
|
+
<locality type='clause'>
|
233
|
+
<referenceFrom>1</referenceFrom>
|
234
|
+
</locality>
|
235
|
+
ISO 712, Clause <strong>1</strong>
|
236
|
+
</eref>
|
237
|
+
<eref type='inline' bibitemid='ISO712'>
|
238
|
+
<locality type='clause'>
|
239
|
+
<referenceFrom>1.5</referenceFrom>
|
240
|
+
</locality>
|
241
|
+
ISO 712, <strong>1.5</strong>
|
242
|
+
</eref>
|
243
|
+
<eref type='inline' bibitemid='ISO712'>
|
244
|
+
<locality type='table'>
|
245
|
+
<referenceFrom>1</referenceFrom>
|
246
|
+
</locality>
|
247
|
+
A
|
248
|
+
</eref>
|
249
|
+
<eref type='inline' bibitemid='ISO712'>
|
250
|
+
<locality type='whole'/>
|
251
|
+
ISO 712, Whole of text
|
252
|
+
</eref>
|
253
|
+
<eref type='inline' bibitemid='ISO712'>
|
254
|
+
<locality type='locality:prelude'>
|
255
|
+
<referenceFrom>7</referenceFrom>
|
256
|
+
</locality>
|
257
|
+
ISO 712, Prelude 7
|
258
|
+
</eref>
|
259
|
+
<eref type='inline' bibitemid='ISO712' citeas='ISO 712'>A</eref>
|
260
|
+
</p>
|
261
|
+
</foreword>
|
262
|
+
</preface>
|
263
|
+
<bibliography>
|
264
|
+
<references id='_normative_references' obligation='informative' normative='true'>
|
265
|
+
<title depth='1'>
|
266
|
+
1
|
267
|
+
<tab/>
|
268
|
+
Normative References
|
269
|
+
</title>
|
270
|
+
<bibitem id='ISO712' type='standard'>
|
271
|
+
<title format='text/plain'>Cereals and cereal products</title>
|
272
|
+
<docidentifier>ISO 712</docidentifier>
|
273
|
+
<contributor>
|
274
|
+
<role type='publisher'/>
|
275
|
+
<organization>
|
276
|
+
<abbreviation>ISO</abbreviation>
|
277
|
+
</organization>
|
278
|
+
</contributor>
|
279
|
+
</bibitem>
|
280
|
+
</references>
|
281
|
+
</bibliography>
|
282
|
+
</iso-standard>
|
283
|
+
OUTPUT
|
284
|
+
end
|
285
|
+
|
286
|
+
|
287
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
RSpec.describe IsoDoc::BSI do
|
5
|
+
FileUtils.rm_f "test.html"
|
6
|
+
it "processes isodoc as ISO: HTML output" do
|
7
|
+
IsoDoc::BSI::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[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
18
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Tahoma", sans-serif;]m)
|
19
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Tahoma", sans-serif;]m)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "processes isodoc as ISO: Chinese HTML output" do
|
23
|
+
FileUtils.rm_f "test.html"
|
24
|
+
IsoDoc::BSI::HtmlConvert.new({script: "Hans"}).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[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
35
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
|
36
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Source Han Sans", sans-serif;]m)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "processes isodoc as ISO: user nominated fonts" do
|
40
|
+
FileUtils.rm_f "test.html"
|
41
|
+
IsoDoc::BSI::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).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[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
|
52
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
|
53
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "processes examples" do
|
57
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
58
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
59
|
+
<preface><foreword>
|
60
|
+
<example id="samplecode">
|
61
|
+
<name>EXAMPLE</name>
|
62
|
+
<p>Hello</p>
|
63
|
+
</example>
|
64
|
+
</foreword></preface>
|
65
|
+
</iso-standard>
|
66
|
+
INPUT
|
67
|
+
#{HTML_HDR}
|
68
|
+
<div>
|
69
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
70
|
+
<div class="boilerplate_legal"/>
|
71
|
+
<div id="samplecode" class="example">
|
72
|
+
<p><span class="example_label">EXAMPLE</span> Hello</p>
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
#{IEC_TITLE1}
|
76
|
+
</div>
|
77
|
+
</body>
|
78
|
+
</html>
|
79
|
+
OUTPUT
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
it "processes sequences of examples" do
|
84
|
+
expect(xmlpp(IsoDoc::BSI::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
85
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
86
|
+
<preface><foreword>
|
87
|
+
<example id="samplecode">
|
88
|
+
<name>EXAMPLE 1</name>
|
89
|
+
<p>Hello</p>
|
90
|
+
</example>
|
91
|
+
<example id="samplecode2">
|
92
|
+
<name>EXAMPLE 2</name>
|
93
|
+
<p>Hello</p>
|
94
|
+
</example>
|
95
|
+
</foreword></preface>
|
96
|
+
</iso-standard>
|
97
|
+
INPUT
|
98
|
+
#{HTML_HDR}
|
99
|
+
<div>
|
100
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
101
|
+
<div class="boilerplate_legal"/>
|
102
|
+
<div id="samplecode" class="example">
|
103
|
+
<p><span class="example_label">EXAMPLE 1</span> Hello</p>
|
104
|
+
</div>
|
105
|
+
<div id="samplecode2" class="example">
|
106
|
+
<p><span class="example_label">EXAMPLE 2</span> Hello</p>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
#{IEC_TITLE1}
|
110
|
+
</div>
|
111
|
+
</body>
|
112
|
+
</html>
|
113
|
+
OUTPUT
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "nokogiri"
|
3
|
+
|
4
|
+
RSpec.describe IsoDoc::BSI::Metadata do
|
5
|
+
it "processes IsoXML metadata" do
|
6
|
+
c = IsoDoc::BSI::HtmlConvert.new({})
|
7
|
+
arr = c.convert_init(<<~"INPUT", "test", false)
|
8
|
+
<iec-standard xmlns="http://riboseinc.com/isoxml">
|
9
|
+
INPUT
|
10
|
+
expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil)).to_s.gsub(/, :/, ",\n:")).to be_equivalent_to <<~"OUTPUT"
|
11
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
12
|
+
<bibdata type="standard">
|
13
|
+
<title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
|
14
|
+
<title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
|
15
|
+
<title type="title-part" language="en" format="text/plain">Rice</title>
|
16
|
+
<title type="title-intro" language="fr" format="text/plain">Céréales et légumineuses</title>
|
17
|
+
<title type="title-main" language="fr" format="text/plain">Spécification et méthodes d'essai</title>
|
18
|
+
<title type="title-part" language="fr" format="text/plain">Riz</title>
|
19
|
+
<docidentifier type="BS">ISO/PreCD3 17301-1</docidentifier>
|
20
|
+
<docnumber>1730</docnumber>
|
21
|
+
<date type="published"><on>2011</on></date>
|
22
|
+
<date type="accessed"><on>2012</on></date>
|
23
|
+
<date type="created"><from>2010</from><to>2011</to></date>
|
24
|
+
<date type="activated"><on>2013</on></date>
|
25
|
+
<date type="obsoleted"><on>2014</on></date>
|
26
|
+
<edition>2</edition>
|
27
|
+
<version>
|
28
|
+
<revision-date>2016-05-01</revision-date>
|
29
|
+
<draft>0.4</draft>
|
30
|
+
</version>
|
31
|
+
<contributor>
|
32
|
+
<role type="author"/>
|
33
|
+
<organization>
|
34
|
+
<name>International Organization for Standardization</name>
|
35
|
+
<abbreviation>ISO</abbreviation>
|
36
|
+
</organization>
|
37
|
+
</contributor>
|
38
|
+
<contributor>
|
39
|
+
<role type="publisher"/>
|
40
|
+
<organization>
|
41
|
+
<name>International Organization for Standardization</name>
|
42
|
+
<abbreviation>ISO</abbreviation>
|
43
|
+
</organization>
|
44
|
+
</contributor>
|
45
|
+
<language>en</language>
|
46
|
+
<script>Latn</script>
|
47
|
+
<status>
|
48
|
+
<stage abbreviation="CD">35</stage>
|
49
|
+
<substage abbreviation="3CD">20</substage>
|
50
|
+
<iteration>3</iteration>
|
51
|
+
</status>
|
52
|
+
<copyright>
|
53
|
+
<from>2016</from>
|
54
|
+
<owner>
|
55
|
+
<organization>
|
56
|
+
<abbreviation>ISO</abbreviation>
|
57
|
+
</organization>
|
58
|
+
</owner>
|
59
|
+
</copyright>
|
60
|
+
<ext>
|
61
|
+
<doctype language=''>international-standard</doctype>
|
62
|
+
<doctype language='fr'>Norme international</doctype>
|
63
|
+
<doctype language='en'>International Standard</doctype>
|
64
|
+
<horizontal language=''>true</horizontal>
|
65
|
+
<horizontal language='fr'>Norme horizontale</horizontal>
|
66
|
+
<horizontal language='en'>Horizontal Standard</horizontal>
|
67
|
+
<function language=''>emc</function>
|
68
|
+
<function language='fr'>Publication fondamentale en CEM</function>
|
69
|
+
<function language='en'>Basic EMC Publication</function>
|
70
|
+
<editorialgroup>
|
71
|
+
<technical-committee number="34">Food products</technical-committee>
|
72
|
+
<subcommittee number="4">Cereals and pulses</subcommittee>
|
73
|
+
<workgroup number="3">Rice Group</workgroup>
|
74
|
+
<secretariat>GB</secretariat>
|
75
|
+
</editorialgroup>
|
76
|
+
<structuredidentifier>
|
77
|
+
<project-number part="1">ISO/PreCD3 17301</project-number>
|
78
|
+
</structuredidentifier>
|
79
|
+
</ext>
|
80
|
+
</bibdata>
|
81
|
+
</iso-standard>
|
82
|
+
INPUT
|
83
|
+
{:accesseddate=>"2012",
|
84
|
+
:activateddate=>"2013",
|
85
|
+
:agency=>"ISO",
|
86
|
+
:circulateddate=>"XXX",
|
87
|
+
:confirmeddate=>"XXX",
|
88
|
+
:copieddate=>"XXX",
|
89
|
+
:createddate=>"2010–2011",
|
90
|
+
:docnumber=>"ISO/PreCD3 17301-1",
|
91
|
+
:docnumeric=>"1730",
|
92
|
+
:docsubtitle=>"Céréales et légumineuses — Spécification et méthodes d'essai — Partie 1: Riz",
|
93
|
+
:docsubtitleintro=>"Céréales et légumineuses",
|
94
|
+
:docsubtitlemain=>"Spécification et méthodes d'essai",
|
95
|
+
:docsubtitlepart=>"Riz",
|
96
|
+
:docsubtitlepartlabel=>"Partie 1",
|
97
|
+
:doctitle=>"Cereals and pulses — Specifications and test methods — Part 1: Rice",
|
98
|
+
:doctitleintro=>"Cereals and pulses",
|
99
|
+
:doctitlemain=>"Specifications and test methods",
|
100
|
+
:doctitlepart=>"Rice",
|
101
|
+
:doctitlepartlabel=>"Part 1",
|
102
|
+
:doctype=>"International Standard",
|
103
|
+
:doctype_display=>"International Standard",
|
104
|
+
:docyear=>"2016",
|
105
|
+
:draft=>"0.4",
|
106
|
+
:draftinfo=>" (draft 0.4, 2016-05-01)",
|
107
|
+
:edition=>"2",
|
108
|
+
:editorialgroup=>["TC 34", "SC 4", "WG 3"],
|
109
|
+
:horizontal=>"true",
|
110
|
+
:implementeddate=>"XXX",
|
111
|
+
:issueddate=>"XXX",
|
112
|
+
:lang=>"en",
|
113
|
+
:obsoleteddate=>"2014",
|
114
|
+
:publisheddate=>"2011",
|
115
|
+
:publisher=>"International Organization for Standardization",
|
116
|
+
:receiveddate=>"XXX",
|
117
|
+
:revdate=>"2016-05-01",
|
118
|
+
:revdate_monthyear=>"May 2016",
|
119
|
+
:sc=>"SC 4",
|
120
|
+
:script=>"Latn",
|
121
|
+
:secretariat=>"GB",
|
122
|
+
:stage=>"35",
|
123
|
+
:stage_int=>35,
|
124
|
+
:stageabbr=>"CD",
|
125
|
+
:statusabbr=>"3CD",
|
126
|
+
:tc=>"TC 34",
|
127
|
+
:transmitteddate=>"XXX",
|
128
|
+
:unchangeddate=>"XXX",
|
129
|
+
:unpublished=>true,
|
130
|
+
:updateddate=>"XXX",
|
131
|
+
:vote_endeddate=>"XXX",
|
132
|
+
:vote_starteddate=>"XXX",
|
133
|
+
:wg=>"WG 3"}
|
134
|
+
OUTPUT
|
135
|
+
end
|
136
|
+
|
137
|
+
it "processes IsoXML metadata" do
|
138
|
+
c = IsoDoc::BSI::HtmlConvert.new({})
|
139
|
+
arr = c.convert_init(<<~"INPUT", "test", false)
|
140
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
141
|
+
INPUT
|
142
|
+
expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil)).to_s.gsub(/, :/, ",\n:")).to be_equivalent_to <<~"OUTPUT"
|
143
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
144
|
+
<bibdata type="standard">
|
145
|
+
<title>
|
146
|
+
<title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
|
147
|
+
<title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
|
148
|
+
<title type="title-part" language="en" format="text/plain">Rice</title>
|
149
|
+
</title>
|
150
|
+
<title>
|
151
|
+
<title type="title-intro" language="fr" format="text/plain">Céréales et légumineuses</title>
|
152
|
+
<title type="title-main" language="fr" format="text/plain">Spécification et méthodes d'essai</title>
|
153
|
+
<title type="title-part" language="fr" format="text/plain">Riz</title>
|
154
|
+
</title>
|
155
|
+
<docidentifier type="BS">ISO/IEC/CD 17301-1-3</docidentifier>
|
156
|
+
<contributor>
|
157
|
+
<role type="author"/>
|
158
|
+
<organization>
|
159
|
+
<name>International Organization for Standardization</name>
|
160
|
+
<abbreviation>ISO</abbreviation>
|
161
|
+
</organization>
|
162
|
+
</contributor>
|
163
|
+
<contributor>
|
164
|
+
<role type="publisher"/>
|
165
|
+
<organization>
|
166
|
+
<name>International Organization for Standardization</name>
|
167
|
+
<abbreviation>ISO</abbreviation>
|
168
|
+
</organization>
|
169
|
+
</contributor>
|
170
|
+
<contributor>
|
171
|
+
<role type="publisher"/>
|
172
|
+
<organization>
|
173
|
+
<name>International Electrotechnical Commission</name>
|
174
|
+
<abbreviation>IEC</abbreviation>
|
175
|
+
</organization>
|
176
|
+
</contributor>
|
177
|
+
<language>en</language>
|
178
|
+
<script>Latn</script>
|
179
|
+
<status>
|
180
|
+
<stage abbreviation="FDIS">50</stage>
|
181
|
+
<substage abbreviation="CFDIS">20</substage>
|
182
|
+
</status>
|
183
|
+
<copyright>
|
184
|
+
<from>2016</from>
|
185
|
+
<owner>
|
186
|
+
<organization>
|
187
|
+
<name>International Organization for Standardization</name>
|
188
|
+
</organization>
|
189
|
+
</owner>
|
190
|
+
</copyright>
|
191
|
+
<relation type="obsoletes">
|
192
|
+
<locality type="clause"><referenceFrom>3.1</referenceFrom></locality>
|
193
|
+
<docidentifier>IEC 8121</docidentifier>
|
194
|
+
</relation>
|
195
|
+
<ext>
|
196
|
+
<doctype>technical-report</doctype>
|
197
|
+
<horizontal>false</horizontal>
|
198
|
+
<editorialgroup>
|
199
|
+
<technical-committee number="34" type="ABC">Food products</technical-committee>
|
200
|
+
<subcommittee number="4" type="DEF">Cereals and pulses</subcommittee>
|
201
|
+
<workgroup number="3" type="GHI">Rice Group</workgroup>
|
202
|
+
</editorialgroup>
|
203
|
+
<ics><code>1.2.3</code></ics>
|
204
|
+
<ics><code>1.2.3</code></ics>
|
205
|
+
<structuredidentifier>
|
206
|
+
<project-number part="1" subpart="3">ISO/IEC/CD 17301</project-number>
|
207
|
+
</strucuredidentifier>
|
208
|
+
</ext>
|
209
|
+
</bibdata>
|
210
|
+
</iso-standard>
|
211
|
+
INPUT
|
212
|
+
{:accesseddate=>"XXX",
|
213
|
+
:agency=>"ISO/IEC",
|
214
|
+
:circulateddate=>"XXX",
|
215
|
+
:confirmeddate=>"XXX",
|
216
|
+
:copieddate=>"XXX",
|
217
|
+
:createddate=>"XXX",
|
218
|
+
:docnumber=>"ISO/IEC/CD 17301-1-3",
|
219
|
+
:docsubtitle=>"Céréales et légumineuses — Spécification et méthodes d'essai — Partie 1–3: Riz",
|
220
|
+
:docsubtitleintro=>"Céréales et légumineuses",
|
221
|
+
:docsubtitlemain=>"Spécification et méthodes d'essai",
|
222
|
+
:docsubtitlepart=>"Riz",
|
223
|
+
:docsubtitlepartlabel=>"Partie 1–3",
|
224
|
+
:doctitle=>"Cereals and pulses — Specifications and test methods — Part 1–3: Rice",
|
225
|
+
:doctitleintro=>"Cereals and pulses",
|
226
|
+
:doctitlemain=>"Specifications and test methods",
|
227
|
+
:doctitlepart=>"Rice",
|
228
|
+
:doctitlepartlabel=>"Part 1–3",
|
229
|
+
:doctype=>"Technical Report",
|
230
|
+
:doctype_display=>"Technical Report",
|
231
|
+
:docyear=>"2016",
|
232
|
+
:editorialgroup=>["ABC 34", "DEF 4", "GHI 3"],
|
233
|
+
:horizontal=>"false",
|
234
|
+
:ics=>"1.2.3, 1.2.3",
|
235
|
+
:implementeddate=>"XXX",
|
236
|
+
:issueddate=>"XXX",
|
237
|
+
:lang=>"en",
|
238
|
+
:obsoleteddate=>"XXX",
|
239
|
+
:obsoletes=>"IEC 8121",
|
240
|
+
:obsoletes_part=>"3.1",
|
241
|
+
:publisheddate=>"XXX",
|
242
|
+
:publisher=>"International Organization for Standardization and International Electrotechnical Commission",
|
243
|
+
:receiveddate=>"XXX",
|
244
|
+
:sc=>"DEF 4",
|
245
|
+
:script=>"Latn",
|
246
|
+
:secretariat=>"XXX",
|
247
|
+
:stage=>"50",
|
248
|
+
:stage_int=>50,
|
249
|
+
:stageabbr=>"FDIS",
|
250
|
+
:statusabbr=>"CFDIS",
|
251
|
+
:tc=>"ABC 34",
|
252
|
+
:transmitteddate=>"XXX",
|
253
|
+
:unchangeddate=>"XXX",
|
254
|
+
:unpublished=>true,
|
255
|
+
:updateddate=>"XXX",
|
256
|
+
:vote_endeddate=>"XXX",
|
257
|
+
:vote_starteddate=>"XXX",
|
258
|
+
:wg=>"GHI 3"}
|
259
|
+
OUTPUT
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|