metanorma-iec 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isodoc/iec/html/html_iec_titlepage.html +1 -0
- data/lib/isodoc/iec/iec.international-standard.xsl +475 -180
- data/lib/isodoc/iec/init.rb +6 -5
- data/lib/isodoc/iec/presentation_xml_convert.rb +3 -3
- data/lib/isodoc/iec/xref.rb +4 -0
- data/lib/metanorma/iec/biblio.rng +37 -8
- data/lib/metanorma/iec/iec.rng +1 -0
- data/lib/metanorma/iec/isodoc.rng +56 -0
- data/lib/metanorma/iec/version.rb +1 -1
- data/metanorma-iec.gemspec +1 -1
- data/spec/isodoc/blocks_spec.rb +146 -202
- data/spec/isodoc/i18n_spec.rb +22 -7
- data/spec/isodoc/iev_spec.rb +7 -7
- data/spec/isodoc/inline_spec.rb +255 -249
- data/spec/isodoc/ref_spec.rb +14 -62
- data/spec/metanorma/base_spec.rb +2 -2
- data/spec/metanorma/inline_spec.rb +6 -6
- metadata +4 -4
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -2,286 +2,292 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes inline formatting" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
input = <<~INPUT
|
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
16
|
INPUT
|
17
|
-
|
18
|
-
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
output = <<~OUTPUT
|
18
|
+
#{HTML_HDR}
|
19
|
+
<div>
|
20
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
21
|
+
<div class="boilerplate_legal"/>
|
22
|
+
<p>
|
23
|
+
<i>A</i> <b>B</b> <sup>C</sup> <sub>D</sub> <tt>E</tt>
|
24
|
+
<s>F</s> <span style="font-variant:small-caps;">G</span> <br/> <hr/>
|
25
|
+
<a id="H"/> <br/>
|
26
|
+
</p>
|
27
|
+
</div>
|
28
|
+
#{IEC_TITLE1}
|
26
29
|
</div>
|
27
|
-
|
28
|
-
|
29
|
-
</body>
|
30
|
-
</html>
|
30
|
+
</body>
|
31
|
+
</html>
|
31
32
|
OUTPUT
|
33
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
34
|
+
.convert("test", input, true)))
|
35
|
+
.to be_equivalent_to xmlpp(output)
|
32
36
|
end
|
33
37
|
|
34
38
|
it "processes links" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
input = <<~INPUT
|
40
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
41
|
+
<preface><foreword>
|
42
|
+
<p>
|
43
|
+
<link target="http://example.com"/>
|
44
|
+
<link target="http://example.com">example</link>
|
45
|
+
<link target="mailto:fred@example.com"/>
|
46
|
+
<link target="mailto:fred@example.com">mailto:fred@example.com</link>
|
47
|
+
</p>
|
48
|
+
</foreword></preface>
|
49
|
+
<sections>
|
50
|
+
</iso-standard>
|
47
51
|
INPUT
|
48
|
-
|
49
|
-
|
50
|
-
<
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
output = <<~OUTPUT
|
53
|
+
#{HTML_HDR}
|
54
|
+
<div>
|
55
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
56
|
+
<div class="boilerplate_legal"/>
|
57
|
+
<p>
|
58
|
+
<a href="http://example.com">http://example.com</a>
|
59
|
+
<a href="http://example.com">example</a>
|
60
|
+
<a href="mailto:fred@example.com">fred@example.com</a>
|
61
|
+
<a href="mailto:fred@example.com">mailto:fred@example.com</a>
|
62
|
+
</p>
|
63
|
+
</div>
|
64
|
+
#{IEC_TITLE1}
|
58
65
|
</div>
|
59
|
-
|
60
|
-
|
61
|
-
</body>
|
62
|
-
</html>
|
66
|
+
</body>
|
67
|
+
</html>
|
63
68
|
OUTPUT
|
69
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
70
|
+
.convert("test", input, true)))
|
71
|
+
.to be_equivalent_to xmlpp(output)
|
64
72
|
end
|
65
73
|
|
66
74
|
it "processes unrecognised markup" do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
input = <<~INPUT
|
76
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
77
|
+
<preface><foreword>
|
78
|
+
<p>
|
79
|
+
<barry fred="http://example.com">example</barry>
|
80
|
+
</p>
|
81
|
+
</foreword></preface>
|
82
|
+
<sections>
|
83
|
+
</iso-standard>
|
76
84
|
INPUT
|
77
|
-
|
78
|
-
|
79
|
-
<
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
85
|
+
output = <<~OUTPUT
|
86
|
+
#{HTML_HDR}
|
87
|
+
<div>
|
88
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
89
|
+
<div class="boilerplate_legal"/>
|
90
|
+
<p>
|
91
|
+
<para><b role="strong"><barry fred="http://example.com">example</barry></b></para>
|
92
|
+
</p>
|
93
|
+
</div>
|
94
|
+
#{IEC_TITLE1}
|
84
95
|
</div>
|
85
|
-
|
86
|
-
|
87
|
-
</body>
|
88
|
-
</html>
|
96
|
+
</body>
|
97
|
+
</html>
|
89
98
|
OUTPUT
|
99
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
100
|
+
.convert("test", input, true)))
|
101
|
+
.to be_equivalent_to xmlpp(output)
|
90
102
|
end
|
91
103
|
|
92
104
|
it "processes AsciiMath and MathML" do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
105
|
+
input = <<~INPUT
|
106
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
107
|
+
<preface><foreword>
|
108
|
+
<p>
|
109
|
+
<stem type="AsciiMath">A</stem>
|
110
|
+
<stem type="MathML"><m:math><m:row>X</m:row></m:math></stem>
|
111
|
+
<stem type="None">Latex?</stem>
|
112
|
+
</p>
|
113
|
+
</foreword></preface>
|
114
|
+
<sections>
|
115
|
+
</iso-standard>
|
104
116
|
INPUT
|
105
|
-
|
106
|
-
|
107
|
-
<
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
<m:
|
113
|
-
|
114
|
-
|
115
|
-
|
117
|
+
output = <<~OUTPUT
|
118
|
+
#{HTML_HDR.sub(/<html/, "<html xmlns:m='m'")}
|
119
|
+
<div>
|
120
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
121
|
+
<div class="boilerplate_legal"/>
|
122
|
+
<p>
|
123
|
+
<span class="stem">(#(A)#)</span>
|
124
|
+
<span class="stem"><m:math>
|
125
|
+
<m:row>X</m:row>
|
126
|
+
</m:math></span>
|
127
|
+
<span class="stem">Latex?</span>
|
128
|
+
</p>
|
129
|
+
</div>
|
130
|
+
#{IEC_TITLE1}
|
116
131
|
</div>
|
117
|
-
|
118
|
-
|
119
|
-
</body>
|
120
|
-
</html>
|
132
|
+
</body>
|
133
|
+
</html>
|
121
134
|
OUTPUT
|
135
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
136
|
+
.convert("test", input, true)
|
137
|
+
.sub(/<html/, "<html xmlns:m='m'")))
|
138
|
+
.to be_equivalent_to xmlpp(output)
|
122
139
|
end
|
123
140
|
|
124
141
|
it "overrides AsciiMath delimiters" do
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
142
|
+
input = <<~INPUT
|
143
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
144
|
+
<preface><foreword>
|
145
|
+
<p>
|
146
|
+
<stem type="AsciiMath">A</stem>
|
147
|
+
(#((Hello))#)
|
148
|
+
</p>
|
149
|
+
</foreword></preface>
|
150
|
+
<sections>
|
151
|
+
</iso-standard>
|
135
152
|
INPUT
|
136
|
-
|
137
|
-
|
138
|
-
<
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
153
|
+
output = <<~OUTPUT
|
154
|
+
#{HTML_HDR}
|
155
|
+
<div>
|
156
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
157
|
+
<div class="boilerplate_legal"/>
|
158
|
+
<p>
|
159
|
+
<span class="stem">(#(((A)#)))</span>
|
160
|
+
(#((Hello))#)
|
161
|
+
</p>
|
162
|
+
</div>
|
163
|
+
#{IEC_TITLE1}
|
144
164
|
</div>
|
145
|
-
|
146
|
-
|
147
|
-
</body>
|
148
|
-
</html>
|
165
|
+
</body>
|
166
|
+
</html>
|
149
167
|
OUTPUT
|
168
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
169
|
+
.convert("test", input, true)))
|
170
|
+
.to be_equivalent_to xmlpp(output)
|
150
171
|
end
|
151
172
|
|
152
173
|
it "processes eref content" do
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
<bibitem id="ISO712" type="standard">
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
</bibitem>
|
183
|
-
|
184
|
-
|
185
|
-
|
174
|
+
input = <<~INPUT
|
175
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
176
|
+
<preface><foreword>
|
177
|
+
<p>
|
178
|
+
<eref type="inline" bibitemid="IEV" citeas="IEV"><locality type="clause"><referenceFrom>1-2-3</referenceFrom></locality></eref>
|
179
|
+
<eref type="inline" bibitemid="ISO712" citeas="ISO 712"/>
|
180
|
+
<eref type="inline" bibitemid="ISO712"/>
|
181
|
+
<eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
|
182
|
+
<eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref>
|
183
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
|
184
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="list"><referenceFrom>a</referenceFrom></locality></eref>
|
185
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
|
186
|
+
<eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1.5</referenceFrom></locality></eref>
|
187
|
+
<eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality>A</eref>
|
188
|
+
<eref type="inline" bibitemid="ISO712"><locality type="whole"></locality></eref>
|
189
|
+
<eref type="inline" bibitemid="ISO712"><locality type="locality:prelude"><referenceFrom>7</referenceFrom></locality></eref>
|
190
|
+
<eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
|
191
|
+
</p>
|
192
|
+
</foreword></preface>
|
193
|
+
<bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
|
194
|
+
<bibitem id="ISO712" type="standard">
|
195
|
+
<title format="text/plain">Cereals and cereal products</title>
|
196
|
+
<docidentifier>ISO 712</docidentifier>
|
197
|
+
<contributor>
|
198
|
+
<role type="publisher"/>
|
199
|
+
<organization>
|
200
|
+
<abbreviation>ISO</abbreviation>
|
201
|
+
</organization>
|
202
|
+
</contributor>
|
203
|
+
</bibitem>
|
204
|
+
</references>
|
205
|
+
</bibliography>
|
206
|
+
</iso-standard>
|
186
207
|
INPUT
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
</preface>
|
263
|
-
<bibliography>
|
264
|
-
<references id='_normative_references' obligation='informative' normative='true' displayorder="2">
|
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>
|
208
|
+
output = <<~OUTPUT
|
209
|
+
<foreword displayorder="1">
|
210
|
+
<p>
|
211
|
+
<eref type='inline' bibitemid='IEV' citeas='IEV'>
|
212
|
+
<locality type='clause'>
|
213
|
+
<referenceFrom>1-2-3</referenceFrom>
|
214
|
+
</locality>
|
215
|
+
<span class='stdpublisher'>IEV</span>, <span class='citesec'>1-2-3</span>
|
216
|
+
</eref>
|
217
|
+
<eref type='inline' bibitemid='ISO712' citeas='ISO 712'><span class='stdpublisher'>ISO</span>
|
218
|
+
<span class='stddocNumber'>712</span>
|
219
|
+
</eref>
|
220
|
+
<eref type='inline' bibitemid='ISO712'>ISO 712</eref>
|
221
|
+
<eref type='inline' bibitemid='ISO712'>
|
222
|
+
<locality type='table'>
|
223
|
+
<referenceFrom>1</referenceFrom>
|
224
|
+
</locality>
|
225
|
+
ISO 712, <span class='citetbl'>Table 1</span>
|
226
|
+
</eref>
|
227
|
+
<eref type='inline' bibitemid='ISO712'>
|
228
|
+
<locality type='table'>
|
229
|
+
<referenceFrom>1</referenceFrom>
|
230
|
+
<referenceTo>1</referenceTo>
|
231
|
+
</locality>
|
232
|
+
ISO 712, <span class='citetbl'>Table 1–1</span>
|
233
|
+
</eref>
|
234
|
+
<eref type='inline' bibitemid='ISO712'>
|
235
|
+
<locality type='clause'>
|
236
|
+
<referenceFrom>1</referenceFrom>
|
237
|
+
</locality>
|
238
|
+
<locality type='table'>
|
239
|
+
<referenceFrom>1</referenceFrom>
|
240
|
+
</locality>
|
241
|
+
ISO 712, <span class='citesec'>Clause 1</span>, <span class='citetbl'>Table 1</span>
|
242
|
+
</eref>
|
243
|
+
<eref type='inline' bibitemid='ISO712'>
|
244
|
+
<locality type='clause'>
|
245
|
+
<referenceFrom>1</referenceFrom>
|
246
|
+
</locality>
|
247
|
+
<locality type='list'>
|
248
|
+
<referenceFrom>a</referenceFrom>
|
249
|
+
</locality>
|
250
|
+
ISO 712, <span class='citesec'>Clause 1</span> a)
|
251
|
+
</eref>
|
252
|
+
<eref type='inline' bibitemid='ISO712'>
|
253
|
+
<locality type='clause'>
|
254
|
+
<referenceFrom>1</referenceFrom>
|
255
|
+
</locality>
|
256
|
+
ISO 712, <span class='citesec'>Clause 1</span>
|
257
|
+
</eref>
|
258
|
+
<eref type='inline' bibitemid='ISO712'>
|
259
|
+
<locality type='clause'>
|
260
|
+
<referenceFrom>1.5</referenceFrom>
|
261
|
+
</locality>
|
262
|
+
ISO 712, <span class='citesec'>1.5</span>
|
263
|
+
</eref>
|
264
|
+
<eref type='inline' bibitemid='ISO712'>
|
265
|
+
<locality type='table'>
|
266
|
+
<referenceFrom>1</referenceFrom>
|
267
|
+
</locality>
|
268
|
+
A
|
269
|
+
</eref>
|
270
|
+
<eref type='inline' bibitemid='ISO712'>
|
271
|
+
<locality type='whole'/>
|
272
|
+
ISO 712, Whole of text
|
273
|
+
</eref>
|
274
|
+
<eref type='inline' bibitemid='ISO712'>
|
275
|
+
<locality type='locality:prelude'>
|
276
|
+
<referenceFrom>7</referenceFrom>
|
277
|
+
</locality>
|
278
|
+
ISO 712, Prelude 7
|
279
|
+
</eref>
|
280
|
+
<eref type='inline' bibitemid='ISO712' citeas='ISO 712'>A</eref>
|
281
|
+
</p>
|
282
|
+
</foreword>
|
283
283
|
OUTPUT
|
284
|
+
expect(xmlpp(
|
285
|
+
Nokogiri::XML(
|
286
|
+
IsoDoc::Iec::PresentationXMLConvert.new({})
|
287
|
+
.convert("test", input, true),
|
288
|
+
)
|
289
|
+
.at("//xmlns:foreword").to_xml,
|
290
|
+
))
|
291
|
+
.to be_equivalent_to xmlpp(output)
|
284
292
|
end
|
285
|
-
|
286
|
-
|
287
293
|
end
|