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.
@@ -2,286 +2,292 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
4
  it "processes inline formatting" do
5
- expect(xmlpp(IsoDoc::Iec::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>
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
- #{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>
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
- #{IEC_TITLE1}
28
- </div>
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
- expect(xmlpp(IsoDoc::Iec::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>
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
- #{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>
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
- #{IEC_TITLE1}
60
- </div>
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
- expect(xmlpp(IsoDoc::Iec::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>
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
- #{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>
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">&lt;barry fred="http://example.com"&gt;example&lt;/barry&gt;</b></para>
92
+ </p>
93
+ </div>
94
+ #{IEC_TITLE1}
84
95
  </div>
85
- #{IEC_TITLE1}
86
- </div>
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
- expect(xmlpp(IsoDoc::Iec::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>
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
- #{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>
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
- #{IEC_TITLE1}
118
- </div>
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
- expect(xmlpp(IsoDoc::Iec::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>
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
- #{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>
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
- #{IEC_TITLE1}
146
- </div>
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
- expect(xmlpp(IsoDoc::Iec::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>
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
- <?xml version='1.0'?>
188
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
189
- <preface>
190
- <foreword displayorder="1">
191
- <p>
192
- <eref type='inline' bibitemid='IEV' citeas='IEV'>
193
- <locality type='clause'>
194
- <referenceFrom>1-2-3</referenceFrom>
195
- </locality>
196
- IEV, 1-2-3
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&#x2013;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 1, 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 1 a)
230
- </eref>
231
- <eref type='inline' bibitemid='ISO712'>
232
- <locality type='clause'>
233
- <referenceFrom>1</referenceFrom>
234
- </locality>
235
- ISO 712, Clause 1
236
- </eref>
237
- <eref type='inline' bibitemid='ISO712'>
238
- <locality type='clause'>
239
- <referenceFrom>1.5</referenceFrom>
240
- </locality>
241
- ISO 712, 1.5
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' 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&#x2013;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