metanorma-iec 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -121,7 +121,7 @@ RSpec.describe Asciidoctor::Iec do
121
121
  #{BLANK_HDR}
122
122
  <preface>
123
123
  <foreword id="_" obligation="informative">
124
- <title>Foreword</title>
124
+ <title>FOREWORD</title>
125
125
  <p id="_">
126
126
  <eref type="inline" bibitemid="iso216" citeas="ISO 216"/>
127
127
  </p>
@@ -189,7 +189,7 @@ RSpec.describe Asciidoctor::Iec do
189
189
  INPUT
190
190
  #{BLANK_HDR}
191
191
  <sections></sections>
192
- <bibliography><references id="_" obligation="informative" normative="true"><title>Normative References</title>
192
+ <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
193
193
  <p id="_">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>
194
194
  <bibitem id="iso216" type="standard">
195
195
  <title format="text/plain">Reference</title>
@@ -68,7 +68,7 @@ RSpec.describe Asciidoctor::Iec do
68
68
  <sections> </sections>
69
69
  <bibliography>
70
70
  <references id='_' obligation='informative' normative="true">
71
- <title>Normative References</title>
71
+ <title>Normative references</title>
72
72
  <p id='_'>There are no normative references in this document.</p>
73
73
  <bibitem id='A'>
74
74
  <formattedref format='application/x-isodoc+xml'>
@@ -158,4 +158,77 @@ INPUT
158
158
 
159
159
  OUTPUT
160
160
  end
161
+
162
+ it "uses IEV introduction title" do
163
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
164
+ = Document title
165
+ Author
166
+ :docfile: test.adoc
167
+ :nodoc:
168
+ :novalid:
169
+ :no-isobib:
170
+ :docnumber: 60050
171
+
172
+ == Introduction
173
+
174
+ Text
175
+ INPUT
176
+ <?xml version='1.0' encoding='UTF-8'?>
177
+ <iec-standard xmlns='https://www.metanorma.org/ns/iec'>
178
+ <bibdata type='standard'>
179
+ <docidentifier type='ISO'>IEC 60050 ED 1</docidentifier>
180
+ <docnumber>60050</docnumber>
181
+ <contributor>
182
+ <role type='author'/>
183
+ <organization>
184
+ <name>International Electrotechnical Commission</name>
185
+ <abbreviation>IEC</abbreviation>
186
+ </organization>
187
+ </contributor>
188
+ <contributor>
189
+ <role type='publisher'/>
190
+ <organization>
191
+ <name>International Electrotechnical Commission</name>
192
+ <abbreviation>IEC</abbreviation>
193
+ </organization>
194
+ </contributor>
195
+ <language>en</language>
196
+ <script>Latn</script>
197
+ <status>
198
+ <stage abbreviation='PPUB'>60</stage>
199
+ <substage abbreviation='PPUB'>60</substage>
200
+ </status>
201
+ <copyright>
202
+ <from>2020</from>
203
+ <owner>
204
+ <organization>
205
+ <name>International Electrotechnical Commission</name>
206
+ <abbreviation>IEC</abbreviation>
207
+ </organization>
208
+ </owner>
209
+ </copyright>
210
+ <ext>
211
+ <doctype>article</doctype>
212
+ <editorialgroup>
213
+ <technical-committee/>
214
+ <subcommittee/>
215
+ <workgroup/>
216
+ </editorialgroup>
217
+ <structuredidentifier>
218
+ <project-number>IEC 60050</project-number>
219
+ </structuredidentifier>
220
+ <stagename>International standard</stagename>
221
+ </ext>
222
+ </bibdata>
223
+ #{BOILERPLATE}
224
+ <preface>
225
+ <introduction id='_' obligation='informative'>
226
+ <title>INTRODUCTION&lt;br/&gt;Principles and rules followed</title>
227
+ <p id='_'>Text</p>
228
+ </introduction>
229
+ </preface>
230
+ <sections> </sections>
231
+ </iec-standard>
232
+ OUTPUT
233
+ end
161
234
  end
@@ -128,7 +128,7 @@ RSpec.describe Asciidoctor::Iec do
128
128
  <sections>
129
129
 
130
130
  </sections><bibliography><references id="_" obligation="informative" normative="true">
131
- <title>Normative References</title>
131
+ <title>Normative references</title>
132
132
  <p id="_">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>
133
133
  <bibitem id="ISO712">
134
134
  <formattedref format="application/x-isodoc+xml">Reference</formattedref>
@@ -54,13 +54,14 @@ RSpec.describe Asciidoctor::Iec do
54
54
  INPUT
55
55
  #{BLANK_HDR}
56
56
  <preface><foreword id="_" obligation="informative">
57
- <title>Foreword</title>
57
+ <title>FOREWORD</title>
58
58
  <p id="_">Text</p>
59
- </foreword><introduction id="_" obligation="informative"><title>Introduction</title><clause id="_" inline-header="false" obligation="informative">
59
+ </foreword><introduction id="_" obligation="informative">
60
+ <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
60
61
  <title>Introduction Subsection</title>
61
62
  </clause>
62
63
  </introduction></preface><sections>
63
- <clause id="_" obligation="normative">
64
+ <clause id="_" obligation="normative" type="scope" inline-header='false'>
64
65
  <title>Scope</title>
65
66
  <p id="_">Text</p>
66
67
  </clause>
@@ -98,8 +99,8 @@ RSpec.describe Asciidoctor::Iec do
98
99
  <preferred>Term2</preferred>
99
100
  </term>
100
101
  </terms>
101
- <definitions id="_"><title>Symbols and Abbreviated Terms</title></definitions></clause>
102
- <definitions id="_"><title>Symbols and Abbreviated Terms</title></definitions>
102
+ <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions></clause>
103
+ <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions>
103
104
  <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
104
105
  <title>Introduction</title>
105
106
  </clause>
@@ -119,7 +120,7 @@ RSpec.describe Asciidoctor::Iec do
119
120
  <appendix id="_" inline-header="false" obligation="normative">
120
121
  <title>Appendix 1</title>
121
122
  </appendix></annex><bibliography><references id="_" obligation="informative" normative="true">
122
- <title>Normative References</title><p id="_">There are no normative references in this document.</p>
123
+ <title>Normative references</title><p id="_">There are no normative references in this document.</p>
123
124
  </references><clause id="_" obligation="informative">
124
125
  <title>Bibliography</title>
125
126
  <references id="_" obligation="informative" normative="false">
@@ -191,16 +192,17 @@ RSpec.describe Asciidoctor::Iec do
191
192
  #{BLANK_HDR}
192
193
  <preface>
193
194
  <foreword id="_" obligation="informative">
194
- <title>Foreword</title>
195
+ <title>FOREWORD</title>
195
196
  <p id="_">Text</p>
196
197
  </foreword>
197
- <introduction id="_" obligation="informative"><title>Introduction</title><clause id="_" inline-header="false" obligation="informative">
198
+ <introduction id="_" obligation="informative">
199
+ <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
198
200
  <title>Introduction Subsection</title>
199
201
  </clause>
200
202
  </introduction>
201
203
  </preface>
202
204
  <sections>
203
- <clause id="_" obligation="normative">
205
+ <clause id="_" obligation="normative" type="scope" inline-header='false'>
204
206
  <title>Scope</title>
205
207
  <p id="_">Text</p>
206
208
  </clause>
@@ -214,7 +216,7 @@ RSpec.describe Asciidoctor::Iec do
214
216
  </term>
215
217
  </terms>
216
218
  <clause id='_' obligation='normative'>
217
- <title>Terms and definitions</title>
219
+ <title>Terms, definitions, symbols and abbreviated terms</title>
218
220
  <terms id='_' obligation='normative'>
219
221
  <title>Normal Terms</title>
220
222
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
@@ -240,12 +242,12 @@ RSpec.describe Asciidoctor::Iec do
240
242
  <preferred>Term2</preferred>
241
243
  </term>
242
244
  </terms>
243
- <definitions id='_'>
244
- <title>Σύμβολα και Συντομογραφίες</title>
245
+ <definitions id='_' obligation="normative">
246
+ <title>Symbols and abbreviated terms</title>
245
247
  </definitions>
246
248
  </clause>
247
- <definitions id='_'>
248
- <title>Σύμβολα και Συντομογραφίες</title>
249
+ <definitions id='_' obligation="normative">
250
+ <title>Symbols and abbreviated terms</title>
249
251
  </definitions>
250
252
  <clause id='_' inline-header='false' obligation='normative'>
251
253
  <title>Clause 4</title>
@@ -268,7 +270,7 @@ RSpec.describe Asciidoctor::Iec do
268
270
  </annex>
269
271
  <bibliography>
270
272
  <references id='_' obligation='informative' normative="true">
271
- <title>Normative References</title>
273
+ <title>Normative references</title>
272
274
  <p id="_">There are no normative references in this document.</p>
273
275
  </references>
274
276
  <clause id='_' obligation='informative'>
@@ -80,10 +80,11 @@ RSpec.describe IsoDoc::Iec do
80
80
  </dd>
81
81
  </dl>
82
82
  <note id="_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0">
83
+ <name>NOTE</name>
83
84
  <p id="_511aaa98-4116-42af-8e5b-c87cdf5bfdc8">[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p>
84
85
  </note>
85
86
  </formula>
86
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935">
87
+ <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935"><name>1</name>
87
88
  <stem type="AsciiMath">r = 1 %</stem>
88
89
  </formula>
89
90
  </foreword></preface>
@@ -151,4 +152,68 @@ RSpec.describe IsoDoc::Iec do
151
152
  OUTPUT
152
153
  end
153
154
 
155
+ it "cross-references formulae" do
156
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).gsub(%r{^.*<body}m, "<body").gsub(%r{</body>.*}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
157
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
158
+ <preface>
159
+ <foreword>
160
+ <p>
161
+ <xref target="N1"/>
162
+ <xref target="N2"/>
163
+ </p>
164
+ </foreword>
165
+ </preface>
166
+ <sections>
167
+ <clause id="intro"><title>First</title>
168
+ <formula id="N1">
169
+ <stem type="AsciiMath">r = 1 %</stem>
170
+ </formula>
171
+ <clause id="xyz"><title>Preparatory</title>
172
+ <formula id="N2" inequality="true">
173
+ <stem type="AsciiMath">r = 1 %</stem>
174
+ </formula>
175
+ <xref target="N2"/>
176
+ </clause>
177
+ </sections>
178
+ </iso-standard>
179
+ INPUT
180
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
181
+ <preface>
182
+ <foreword>
183
+ <p>
184
+ <xref target='N1'>Clause 1, Equation (1)</xref>
185
+ <xref target='N2'>1.1, Inequality (2)</xref>
186
+ </p>
187
+ </foreword>
188
+ </preface>
189
+ <sections>
190
+ <clause id='intro'>
191
+ <title depth='1'>
192
+ 1
193
+ <tab/>
194
+ First
195
+ </title>
196
+ <formula id='N1'>
197
+ <name>1</name>
198
+ <stem type='AsciiMath'>r = 1 %</stem>
199
+ </formula>
200
+ <clause id='xyz'>
201
+ <title depth='2'>
202
+ 1.1
203
+ <tab/>
204
+ Preparatory
205
+ </title>
206
+ <formula id='N2' inequality='true'>
207
+ <name>2</name>
208
+ <stem type='AsciiMath'>r = 1 %</stem>
209
+ </formula>
210
+ <xref target='N2'>Inequality (2)</xref>
211
+ </clause>
212
+ </clause>
213
+ </sections>
214
+ </iso-standard>
215
+ OUTPUT
216
+ end
217
+
218
+
154
219
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
4
  it "processes English" do
5
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
5
+ input = <<~INPUT
6
6
  <iso-standard xmlns="http://riboseinc.com/isoxml">
7
7
  <bibdata>
8
8
  <docnumber>1</docnumber>
@@ -18,7 +18,7 @@ RSpec.describe IsoDoc do
18
18
  </clause>
19
19
  <p>This is patent boilerplate</p>
20
20
  </introduction></preface><sections>
21
- <clause id="D" obligation="normative">
21
+ <clause id="D" obligation="normative" type="scope">
22
22
  <title>Scope</title>
23
23
  <p id="E">Text</p>
24
24
  </clause>
@@ -71,6 +71,78 @@ RSpec.describe IsoDoc do
71
71
  </bibliography>
72
72
  </iso-standard>
73
73
  INPUT
74
+
75
+ presxml = <<~OUTPUT
76
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
77
+ <bibdata>
78
+ <docnumber>1</docnumber>
79
+ <language>en</language>
80
+ </bibdata>
81
+ <preface>
82
+ <foreword obligation="informative">
83
+ <title>Foreword</title>
84
+ <p id="A">This is a preamble</p>
85
+ </foreword>
86
+ <introduction id="B" obligation="informative"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
87
+ <title depth="2">0.1<tab/>Introduction Subsection</title>
88
+ </clause>
89
+ <p>This is patent boilerplate</p>
90
+ </introduction></preface><sections>
91
+ <clause id="D" obligation="normative" type="scope">
92
+ <title depth="1">1<tab/>Scope</title>
93
+ <p id="E">Text</p>
94
+ </clause>
95
+
96
+ <clause id="H" obligation="normative"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
97
+ <title depth="2">3.1<tab/>Normal Terms</title>
98
+ <term id="J"><name>3.1.1</name>
99
+ <preferred>Term2</preferred>
100
+ </term>
101
+ </terms>
102
+ <definitions id="K"><title>3.2</title>
103
+ <dl>
104
+ <dt>Symbol</dt>
105
+ <dd>Definition</dd>
106
+ </dl>
107
+ </definitions>
108
+ </clause>
109
+ <definitions id="L"><title>4</title>
110
+ <dl>
111
+ <dt>Symbol</dt>
112
+ <dd>Definition</dd>
113
+ </dl>
114
+ </definitions>
115
+ <clause id="M" inline-header="false" obligation="normative"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
116
+ <title depth="2">5.1<tab/>Introduction</title>
117
+ </clause>
118
+ <clause id="O" inline-header="false" obligation="normative">
119
+ <title depth="2">5.2<tab/>Clause 4.2</title>
120
+ </clause></clause>
121
+
122
+ </sections><annex id="P" inline-header="false" obligation="normative">
123
+ <title><strong>Annex A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
124
+ <clause id="Q" inline-header="false" obligation="normative">
125
+ <title depth="2">A.1<tab/>Annex A.1</title>
126
+ <clause id="Q1" inline-header="false" obligation="normative">
127
+ <title depth="3">A.1.1<tab/>Annex A.1a</title>
128
+ </clause>
129
+ </clause>
130
+ <appendix id="Q2" inline-header="false" obligation="normative">
131
+ <title depth="2">Appendix 1<tab/>An Appendix</title>
132
+ </appendix>
133
+ </annex><bibliography><references id="R" obligation="informative" normative="true">
134
+ <title depth="1">2<tab/>Normative References</title>
135
+ </references><clause id="S" obligation="informative">
136
+ <title depth="1">Bibliography</title>
137
+ <references id="T" obligation="informative" normative="false">
138
+ <title depth="2">Bibliography Subsection</title>
139
+ </references>
140
+ </clause>
141
+ </bibliography>
142
+ </iso-standard>
143
+ OUTPUT
144
+
145
+ html = <<~OUTPUT
74
146
  #{HTML_HDR}
75
147
  <div>
76
148
  <h1 class="ForewordTitle">FOREWORD</h1>
@@ -79,7 +151,7 @@ RSpec.describe IsoDoc do
79
151
  </div>
80
152
  <br/>
81
153
  <div class="Section3" id="B">
82
- <h1 class="IntroTitle">0&#160; INTRODUCTION</h1>
154
+ <h1 class="IntroTitle">0&#160; Introduction</h1>
83
155
  <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
84
156
 
85
157
  </div>
@@ -91,7 +163,7 @@ RSpec.describe IsoDoc do
91
163
  <p id="E">Text</p>
92
164
  </div>
93
165
  <div>
94
- <h1>2&#160; Normative references</h1>
166
+ <h1>2&#160; Normative References</h1>
95
167
  </div>
96
168
  <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
97
169
  <div id="I"><h2>3.1&#160; Normal Terms</h2>
@@ -99,11 +171,11 @@ RSpec.describe IsoDoc do
99
171
  <p class="TermNum" id="J">3.1.1</p>
100
172
  <p class="Terms" style="text-align:left;">Term2</p>
101
173
 
102
- </div><div id="K"><h2>3.2&#160; Symbols and abbreviated terms</h2>
174
+ </div><div id="K"><h2>3.2</h2>
103
175
  <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
104
176
  </div></div>
105
177
  <div id="L" class="Symbols">
106
- <h1>4&#160; Symbols and abbreviated terms</h1>
178
+ <h1>4</h1>
107
179
  <dl>
108
180
  <dt>
109
181
  <p>Symbol</p>
@@ -122,7 +194,7 @@ RSpec.describe IsoDoc do
122
194
  </div>
123
195
  <br/>
124
196
  <div id="P" class="Section3">
125
- <h1 class="Annex"><b>Annex A</b><br/><br/>(normative)<br/><br/><b>Annex</b></h1>
197
+ <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
126
198
  <div id="Q"><h2>A.1&#160; Annex A.1</h2>
127
199
 
128
200
  <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
@@ -144,10 +216,12 @@ RSpec.describe IsoDoc do
144
216
  </body>
145
217
  </html>
146
218
  OUTPUT
219
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
220
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
147
221
  end
148
222
 
149
223
  it "defaults to English" do
150
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
224
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
151
225
  <iso-standard xmlns="http://riboseinc.com/isoxml">
152
226
  <bibdata>
153
227
  <language>tlh</language>
@@ -162,7 +236,7 @@ RSpec.describe IsoDoc do
162
236
  </clause>
163
237
  <p>This is patent boilerplate</p>
164
238
  </introduction></preface><sections>
165
- <clause id="D" obligation="normative">
239
+ <clause id="D" obligation="normative" type="scope">
166
240
  <title>Scope</title>
167
241
  <p id="E">Text</p>
168
242
  </clause>
@@ -215,83 +289,146 @@ RSpec.describe IsoDoc do
215
289
  </bibliography>
216
290
  </iso-standard>
217
291
  INPUT
218
- #{HTML_HDR.gsub(/"en"/, '"tlh"')}
219
- <div>
220
- <h1 class="ForewordTitle">FOREWORD</h1>
221
- <div class="boilerplate_legal"/>
222
- <p id="A">This is a preamble</p>
223
- </div>
224
- <br/>
225
- <div class="Section3" id="B">
226
- <h1 class="IntroTitle">0&#160; INTRODUCTION</h1>
227
- <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
228
-
229
- </div>
230
- <p>This is patent boilerplate</p>
231
- </div>
232
- #{IEC_TITLE1}
233
- <div id="D">
234
- <h1>1&#160; Scope</h1>
235
- <p id="E">Text</p>
236
- </div>
237
- <div>
238
- <h1>2&#160; Normative references</h1>
239
- </div>
240
- <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
241
- <div id="I"><h2>3.1&#160; Normal Terms</h2>
242
-
243
- <p class="TermNum" id="J">3.1.1</p>
244
- <p class="Terms" style="text-align:left;">Term2</p>
245
-
246
- </div><div id="K"><h2>3.2&#160; Symbols and abbreviated terms</h2>
247
- <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
248
- </div></div>
249
- <div id="L" class="Symbols">
250
- <h1>4&#160; Symbols and abbreviated terms</h1>
292
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
293
+ <bibdata>
294
+ <language>tlh</language>
295
+ </bibdata>
296
+ <preface>
297
+ <foreword obligation='informative'>
298
+ <title>Foreword</title>
299
+ <p id='A'>This is a preamble</p>
300
+ </foreword>
301
+ <introduction id='B' obligation='informative'>
302
+ <title depth='1'>
303
+ 0
304
+ <tab/>
305
+ Introduction
306
+ </title>
307
+ <clause id='C' inline-header='false' obligation='informative'>
308
+ <title depth='2'>
309
+ 0.1
310
+ <tab/>
311
+ Introduction Subsection
312
+ </title>
313
+ </clause>
314
+ <p>This is patent boilerplate</p>
315
+ </introduction>
316
+ </preface>
317
+ <sections>
318
+ <clause id='D' obligation='normative' type="scope">
319
+ <title depth='1'>
320
+ 1
321
+ <tab/>
322
+ Scope
323
+ </title>
324
+ <p id='E'>Text</p>
325
+ </clause>
326
+ <clause id='H' obligation='normative'>
327
+ <title depth='1'>
328
+ 3
329
+ <tab/>
330
+ Terms, definitions, symbols and abbreviated terms
331
+ </title>
332
+ <terms id='I' obligation='normative'>
333
+ <title depth='2'>
334
+ 3.1
335
+ <tab/>
336
+ Normal Terms
337
+ </title>
338
+ <term id='J'>
339
+ <name>3.1.1</name>
340
+ <preferred>Term2</preferred>
341
+ </term>
342
+ </terms>
343
+ <definitions id='K'>
344
+ <title>3.2</title>
251
345
  <dl>
252
- <dt>
253
- <p>Symbol</p>
254
- </dt>
346
+ <dt>Symbol</dt>
255
347
  <dd>Definition</dd>
256
348
  </dl>
257
- </div>
258
- <div id="M">
259
- <h1>5&#160; Clause 4</h1>
260
- <div id="N"><h2>5.1&#160; Introduction</h2>
261
-
262
- </div>
263
- <div id="O"><h2>5.2&#160; Clause 4.2</h2>
264
-
265
- </div>
266
- </div>
349
+ </definitions>
350
+ </clause>
351
+ <definitions id='L'>
352
+ <title>4</title>
353
+ <dl>
354
+ <dt>Symbol</dt>
355
+ <dd>Definition</dd>
356
+ </dl>
357
+ </definitions>
358
+ <clause id='M' inline-header='false' obligation='normative'>
359
+ <title depth='1'>
360
+ 5
361
+ <tab/>
362
+ Clause 4
363
+ </title>
364
+ <clause id='N' inline-header='false' obligation='normative'>
365
+ <title depth='2'>
366
+ 5.1
367
+ <tab/>
368
+ Introduction
369
+ </title>
370
+ </clause>
371
+ <clause id='O' inline-header='false' obligation='normative'>
372
+ <title depth='2'>
373
+ 5.2
374
+ <tab/>
375
+ Clause 4.2
376
+ </title>
377
+ </clause>
378
+ </clause>
379
+ </sections>
380
+ <annex id='P' inline-header='false' obligation='normative'>
381
+ <title>
382
+ <strong>Annex A</strong>
267
383
  <br/>
268
- <div id="P" class="Section3">
269
- <h1 class="Annex"><b>Annex A</b><br/><br/>(normative)<br/><br/><b>Annex</b></h1>
270
- <div id="Q"><h2>A.1&#160; Annex A.1</h2>
271
-
272
- <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
273
-
274
- </div>
275
- </div>
276
- <div id="Q2"><h2>Appendix 1&#160; An Appendix</h2>
277
-
278
- </div>
279
- </div>
384
+ (normative)
280
385
  <br/>
281
- <div>
282
- <h1 class="Section3">Bibliography</h1>
283
- <div>
284
- <h2 class="Section3">Bibliography Subsection</h2>
285
- </div>
286
- </div>
287
- </div>
288
- </body>
289
- </html>
386
+ <br/>
387
+ <strong>Annex</strong>
388
+ </title>
389
+ <clause id='Q' inline-header='false' obligation='normative'>
390
+ <title depth='2'>
391
+ A.1
392
+ <tab/>
393
+ Annex A.1
394
+ </title>
395
+ <clause id='Q1' inline-header='false' obligation='normative'>
396
+ <title depth='3'>
397
+ A.1.1
398
+ <tab/>
399
+ Annex A.1a
400
+ </title>
401
+ </clause>
402
+ </clause>
403
+ <appendix id='Q2' inline-header='false' obligation='normative'>
404
+ <title depth='2'>
405
+ Appendix 1
406
+ <tab/>
407
+ An Appendix
408
+ </title>
409
+ </appendix>
410
+ </annex>
411
+ <bibliography>
412
+ <references id='R' obligation='informative' normative='true'>
413
+ <title depth='1'>
414
+ 2
415
+ <tab/>
416
+ Normative References
417
+ </title>
418
+ </references>
419
+ <clause id='S' obligation='informative'>
420
+ <title depth='1'>Bibliography</title>
421
+ <references id='T' obligation='informative' normative='false'>
422
+ <title depth='2'>Bibliography Subsection</title>
423
+ </references>
424
+ </clause>
425
+ </bibliography>
426
+ </iso-standard>
290
427
  OUTPUT
291
428
  end
292
429
 
293
430
  it "processes French" do
294
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
431
+ input = <<~INPUT
295
432
  <iso-standard xmlns="http://riboseinc.com/isoxml">
296
433
  <bibdata>
297
434
  <language>fr</language>
@@ -306,7 +443,7 @@ RSpec.describe IsoDoc do
306
443
  </clause>
307
444
  <p>This is patent boilerplate</p>
308
445
  </introduction></preface><sections>
309
- <clause id="D" obligation="normative">
446
+ <clause id="D" obligation="normative" type="scope">
310
447
  <title>Scope</title>
311
448
  <p id="E">Text</p>
312
449
  </clause>
@@ -359,6 +496,77 @@ RSpec.describe IsoDoc do
359
496
  </bibliography>
360
497
  </iso-standard>
361
498
  INPUT
499
+
500
+ presxml = <<~OUTPUT
501
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
502
+ <bibdata>
503
+ <language>fr</language>
504
+ </bibdata>
505
+ <preface>
506
+ <foreword obligation="informative">
507
+ <title>Foreword</title>
508
+ <p id="A">This is a preamble</p>
509
+ </foreword>
510
+ <introduction id="B" obligation="informative"><title depth="1">0<tab/>Introduction</title><clause id="C" inline-header="false" obligation="informative">
511
+ <title depth="2">0.1<tab/>Introduction Subsection</title>
512
+ </clause>
513
+ <p>This is patent boilerplate</p>
514
+ </introduction></preface><sections>
515
+ <clause id="D" obligation="normative" type="scope">
516
+ <title depth="1">1<tab/>Scope</title>
517
+ <p id="E">Text</p>
518
+ </clause>
519
+
520
+ <clause id="H" obligation="normative"><title depth="1">3<tab/>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
521
+ <title depth="2">3.1<tab/>Normal Terms</title>
522
+ <term id="J"><name>3.1.1</name>
523
+ <preferred>Term2</preferred>
524
+ </term>
525
+ </terms>
526
+ <definitions id="K"><title>3.2</title>
527
+ <dl>
528
+ <dt>Symbol</dt>
529
+ <dd>Definition</dd>
530
+ </dl>
531
+ </definitions>
532
+ </clause>
533
+ <definitions id="L"><title>4</title>
534
+ <dl>
535
+ <dt>Symbol</dt>
536
+ <dd>Definition</dd>
537
+ </dl>
538
+ </definitions>
539
+ <clause id="M" inline-header="false" obligation="normative"><title depth="1">5<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
540
+ <title depth="2">5.1<tab/>Introduction</title>
541
+ </clause>
542
+ <clause id="O" inline-header="false" obligation="normative">
543
+ <title depth="2">5.2<tab/>Clause 4.2</title>
544
+ </clause></clause>
545
+
546
+ </sections><annex id="P" inline-header="false" obligation="normative">
547
+ <title><strong>Annexe A</strong><br/>(normative)<br/><br/><strong>Annex</strong></title>
548
+ <clause id="Q" inline-header="false" obligation="normative">
549
+ <title depth="2">A.1<tab/>Annex A.1</title>
550
+ <clause id="Q1" inline-header="false" obligation="normative">
551
+ <title depth="3">A.1.1<tab/>Annex A.1a</title>
552
+ </clause>
553
+ </clause>
554
+ <appendix id="Q2" inline-header="false" obligation="normative">
555
+ <title depth="2">Appendice 1<tab/>An Appendix</title>
556
+ </appendix>
557
+ </annex><bibliography><references id="R" obligation="informative" normative="true">
558
+ <title depth="1">2<tab/>Normative References</title>
559
+ </references><clause id="S" obligation="informative">
560
+ <title depth="1">Bibliography</title>
561
+ <references id="T" obligation="informative" normative="false">
562
+ <title depth="2">Bibliography Subsection</title>
563
+ </references>
564
+ </clause>
565
+ </bibliography>
566
+ </iso-standard>
567
+ OUTPUT
568
+
569
+ html = <<~OUTPUT
362
570
  #{HTML_HDR.sub(/INTERNATIONAL ELECTROTECHNICAL COMMISSION/, "COMMISSION ELECTROTECHNIQUE INTERNATIONALE").
363
571
  gsub(/"en"/, '"fr"')}
364
572
  <div>
@@ -368,7 +576,7 @@ RSpec.describe IsoDoc do
368
576
  </div>
369
577
  <br/>
370
578
  <div class="Section3" id="B">
371
- <h1 class="IntroTitle">0&#160; INTRODUCTION</h1>
579
+ <h1 class="IntroTitle">0&#160; Introduction</h1>
372
580
  <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
373
581
 
374
582
  </div>
@@ -376,23 +584,23 @@ RSpec.describe IsoDoc do
376
584
  </div>
377
585
  #{IEC_TITLE1}
378
586
  <div id="D">
379
- <h1>1&#160; Domaine d'application</h1>
587
+ <h1>1&#160; Scope</h1>
380
588
  <p id="E">Text</p>
381
589
  </div>
382
590
  <div>
383
- <h1>2&#160; R&#233;f&#233;rences normatives</h1>
591
+ <h1>2&#160; Normative References</h1>
384
592
  </div>
385
- <div id="H"><h1>3&#160; Terms, d&#233;finitions, symboles et termes abr&#233;g&#233;s</h1>
593
+ <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1>
386
594
  <div id="I"><h2>3.1&#160; Normal Terms</h2>
387
595
 
388
596
  <p class="TermNum" id="J">3.1.1</p>
389
597
  <p class="Terms" style="text-align:left;">Term2</p>
390
598
 
391
- </div><div id="K"><h2>3.2&#160; Symboles et termes abr&#233;g&#233;s</h2>
599
+ </div><div id="K"><h2>3.2</h2>
392
600
  <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
393
601
  </div></div>
394
602
  <div id="L" class="Symbols">
395
- <h1>4&#160; Symboles et termes abr&#233;g&#233;s</h1>
603
+ <h1>4</h1>
396
604
  <dl>
397
605
  <dt>
398
606
  <p>Symbol</p>
@@ -411,7 +619,7 @@ RSpec.describe IsoDoc do
411
619
  </div>
412
620
  <br/>
413
621
  <div id="P" class="Section3">
414
- <h1 class="Annex"><b>Annexe A</b><br/><br/>(normative)<br/><br/><b>Annex</b></h1>
622
+ <h1 class="Annex"><b>Annexe A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
415
623
  <div id="Q"><h2>A.1&#160; Annex A.1</h2>
416
624
 
417
625
  <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
@@ -424,165 +632,7 @@ RSpec.describe IsoDoc do
424
632
  </div>
425
633
  <br/>
426
634
  <div>
427
- <h1 class="Section3">Bibliographie</h1>
428
- <div>
429
- <h2 class="Section3">Bibliography Subsection</h2>
430
- </div>
431
- </div>
432
- </div>
433
- </body>
434
- </html>
435
- OUTPUT
436
- end
437
-
438
- it "processes Simplified Chinese" do
439
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
440
- <iso-standard xmlns="http://riboseinc.com/isoxml">
441
- <bibdata>
442
- <language>zh</language>
443
- <script>Hans</script>
444
- </bibdata>
445
- <preface>
446
- <foreword obligation="informative">
447
- <title>Foreword</title>
448
- <p id="A">This is a preamble</p>
449
- </foreword>
450
- <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
451
- <title>Introduction Subsection</title>
452
- </clause>
453
- <p>This is patent boilerplate</p>
454
- </introduction></preface><sections>
455
- <clause id="D" obligation="normative">
456
- <title>Scope</title>
457
- <p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref></p>
458
- </clause>
459
-
460
- <clause id="H" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="I" obligation="normative">
461
- <title>Normal Terms</title>
462
- <term id="J">
463
- <preferred>Term2</preferred>
464
- </term>
465
- </terms>
466
- <definitions id="K">
467
- <dl>
468
- <dt>Symbol</dt>
469
- <dd>Definition</dd>
470
- </dl>
471
- </definitions>
472
- </clause>
473
- <definitions id="L">
474
- <dl>
475
- <dt>Symbol</dt>
476
- <dd>Definition</dd>
477
- </dl>
478
- </definitions>
479
- <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
480
- <title>Introduction</title>
481
- </clause>
482
- <clause id="O" inline-header="false" obligation="normative">
483
- <title>Clause 4.2</title>
484
- </clause></clause>
485
-
486
- </sections><annex id="P" inline-header="false" obligation="normative">
487
- <title>Annex</title>
488
- <clause id="Q" inline-header="false" obligation="normative">
489
- <title>Annex A.1</title>
490
- <clause id="Q1" inline-header="false" obligation="normative">
491
- <title>Annex A.1a</title>
492
- </clause>
493
- </clause>
494
- <appendix id="Q2" inline-header="false" obligation="normative">
495
- <title>An Appendix</title>
496
- </appendix>
497
- </annex><bibliography><references id="R" obligation="informative" normative="true">
498
- <title>Normative References</title>
499
- <bibitem id="ISO712" type="standard">
500
- <title format="text/plain">Cereals and cereal products</title>
501
- <docidentifier>ISO 712</docidentifier>
502
- <contributor>
503
- <role type="publisher"/>
504
- <organization>
505
- <abbreviation>ISO</abbreviation>
506
- </organization>
507
- </contributor>
508
- </bibitem>
509
- </references><clause id="S" obligation="informative">
510
- <title>Bibliography</title>
511
- <references id="T" obligation="informative" normative="false">
512
- <title>Bibliography Subsection</title>
513
- </references>
514
- </clause>
515
- </bibliography>
516
- </iso-standard>
517
- INPUT
518
- #{HTML_HDR.gsub(/"en"/, '"zh"').sub(/INTERNATIONAL ELECTROTECHNICAL COMMISSION/, "&#22269;&#38469;&#30005;&#24037;&#22996;&#21592;&#20250;")}
519
- <div>
520
- <h1 class="ForewordTitle">&#21069;&#35328;</h1>
521
- <div class="boilerplate_legal"/>
522
- <p id="A">This is a preamble</p>
523
- </div>
524
- <br/>
525
- <div class="Section3" id="B">
526
- <h1 class="IntroTitle">0&#160; &#24341;&#35328;</h1>
527
- <div id="C"><h2>0.1&#160; Introduction Subsection</h2>
528
-
529
- </div>
530
- <p>This is patent boilerplate</p>
531
- </div>
532
- #{IEC_TITLE1}
533
- <div id="D">
534
- <h1>1&#160; &#33539;&#22260;</h1>
535
- <p id="E">
536
- <a href="#ISO712">ISO 712&#12289;&#31532;1&#8211;<referenceto>1</referenceto>&#34920;</a>
537
- </p>
538
- </div>
539
- <div>
540
- <h1>2&#160; &#35268;&#33539;&#24615;&#24341;&#29992;&#25991;&#20214;</h1>
541
- <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
542
- </div>
543
- <div id="H"><h1>3&#160; &#26415;&#35821;&#12289;&#23450;&#20041;&#12289;&#31526;&#21495;&#12289;&#20195;&#21495;&#21644;&#32553;&#30053;&#35821;</h1>
544
- <div id="I"><h2>3.1&#160; Normal Terms</h2>
545
-
546
- <p class="TermNum" id="J">3.1.1</p>
547
- <p class="Terms" style="text-align:left;">Term2</p>
548
-
549
- </div><div id="K"><h2>3.2&#160; &#31526;&#21495;&#12289;&#20195;&#21495;&#21644;&#32553;&#30053;&#35821;</h2>
550
- <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
551
- </div></div>
552
- <div id="L" class="Symbols">
553
- <h1>4&#160; &#31526;&#21495;&#12289;&#20195;&#21495;&#21644;&#32553;&#30053;&#35821;</h1>
554
- <dl>
555
- <dt>
556
- <p>Symbol</p>
557
- </dt>
558
- <dd>Definition</dd>
559
- </dl>
560
- </div>
561
- <div id="M">
562
- <h1>5&#160; Clause 4</h1>
563
- <div id="N"><h2>5.1&#160; Introduction</h2>
564
-
565
- </div>
566
- <div id="O"><h2>5.2&#160; Clause 4.2</h2>
567
-
568
- </div>
569
- </div>
570
- <br/>
571
- <div id="P" class="Section3">
572
- <h1 class="Annex">&#38468;&#20214;A<br/><br/>&#65288;&#35268;&#33539;&#24615;&#38468;&#24405;&#65289;<br/><br/><b>Annex</b></h1>
573
- <div id="Q"><h2>A.1&#160; Annex A.1</h2>
574
-
575
- <div id="Q1"><h3>A.1.1&#160; Annex A.1a</h3>
576
-
577
- </div>
578
- </div>
579
- <div id="Q2"><h2>&#38468;&#24405;1&#160; An Appendix</h2>
580
-
581
- </div>
582
- </div>
583
- <br/>
584
- <div>
585
- <h1 class="Section3">&#21442;&#32771;&#25991;&#29486;</h1>
635
+ <h1 class="Section3">Bibliography</h1>
586
636
  <div>
587
637
  <h2 class="Section3">Bibliography Subsection</h2>
588
638
  </div>
@@ -591,6 +641,8 @@ RSpec.describe IsoDoc do
591
641
  </body>
592
642
  </html>
593
643
  OUTPUT
644
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
645
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
594
646
  end
595
647
 
596
648
  end