metanorma-iso 1.4.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/iso/base.rb +8 -19
  3. data/lib/asciidoctor/iso/cleanup.rb +2 -3
  4. data/lib/asciidoctor/iso/front.rb +0 -1
  5. data/lib/asciidoctor/iso/front_id.rb +1 -1
  6. data/lib/asciidoctor/iso/isodoc.rng +12 -6
  7. data/lib/asciidoctor/iso/section.rb +5 -11
  8. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -1
  9. data/lib/asciidoctor/iso/validate_section.rb +30 -44
  10. data/lib/isodoc/iso/base_convert.rb +3 -64
  11. data/lib/isodoc/iso/html_convert.rb +2 -1
  12. data/lib/{asciidoctor → isodoc}/iso/i18n-en.yaml +0 -0
  13. data/lib/{asciidoctor → isodoc}/iso/i18n-fr.yaml +0 -0
  14. data/lib/{asciidoctor → isodoc}/iso/i18n-zh-Hans.yaml +0 -0
  15. data/lib/isodoc/iso/i18n.rb +19 -0
  16. data/lib/isodoc/iso/init.rb +33 -0
  17. data/lib/isodoc/iso/metadata.rb +1 -1
  18. data/lib/isodoc/iso/presentation_xml_convert.rb +99 -1
  19. data/lib/isodoc/iso/sections.rb +3 -8
  20. data/lib/isodoc/iso/word_convert.rb +2 -1
  21. data/lib/isodoc/iso/xref.rb +2 -0
  22. data/lib/metanorma/iso/version.rb +1 -1
  23. data/metanorma-iso.gemspec +2 -2
  24. data/spec/asciidoctor-iso/cleanup_spec.rb +4 -4
  25. data/spec/asciidoctor-iso/inline_spec.rb +1 -1
  26. data/spec/asciidoctor-iso/refs_spec.rb +3 -3
  27. data/spec/asciidoctor-iso/section_spec.rb +9 -6
  28. data/spec/asciidoctor-iso/validate_spec.rb +13 -21
  29. data/spec/isodoc/amd_spec.rb +309 -153
  30. data/spec/isodoc/blocks_spec.rb +362 -28
  31. data/spec/isodoc/i18n_spec.rb +468 -108
  32. data/spec/isodoc/inline_spec.rb +99 -31
  33. data/spec/isodoc/iso_spec.rb +95 -29
  34. data/spec/isodoc/postproc_spec.rb +114 -149
  35. data/spec/isodoc/ref_spec.rb +175 -3
  36. data/spec/isodoc/section_spec.rb +148 -82
  37. data/spec/isodoc/table_spec.rb +142 -5
  38. data/spec/isodoc/terms_spec.rb +78 -53
  39. data/spec/isodoc/xref_spec.rb +831 -658
  40. data/spec/metanorma/processor_spec.rb +2 -1
  41. metadata +11 -9
@@ -158,7 +158,7 @@ RSpec.describe IsoDoc do
158
158
  <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</stem>
159
159
  </p>
160
160
  </foreword></preface>
161
- <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
161
+ <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>1<tab/>Normative references</title>
162
162
  <bibitem id="ISO712" type="standard">
163
163
  <title format="text/plain">Cereals and cereal products</title>
164
164
  <docidentifier>ISO 712</docidentifier>
@@ -185,7 +185,7 @@ RSpec.describe IsoDoc do
185
185
  <p class="zzSTDTitle1"/>
186
186
  <div>
187
187
  <h1>1&#160; Normative references</h1>
188
- <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
188
+ <p id="ISO712" class="NormRef">ISO 712, <i>Cereals and cereal products</i></p>
189
189
  </div>
190
190
  </div>
191
191
  </body>
@@ -194,7 +194,7 @@ RSpec.describe IsoDoc do
194
194
  end
195
195
 
196
196
  it "processes eref content" do
197
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
197
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
198
198
  <iso-standard xmlns="http://riboseinc.com/isoxml">
199
199
  <preface><foreword>
200
200
  <p>
@@ -228,34 +228,102 @@ RSpec.describe IsoDoc do
228
228
  </bibliography>
229
229
  </iso-standard>
230
230
  INPUT
231
- #{HTML_HDR}
232
- <br/>
233
- <div>
234
- <h1 class="ForewordTitle">Foreword</h1>
235
- <p>
236
- <a href="#IEV">IEV, 1-2-3</a>
237
- <a href="#ISO712">ISO 712</a>
238
- <a href="#ISO712">ISO 712</a>
239
- <a href="#ISO712">ISO 712, Table 1</a>
240
- <a href="#ISO712">ISO 712, Table 1&#8211;1</a>
241
- <a href="#ISO712">ISO 712, Clause 1, Table 1</a>
242
- <a href="#ISO712">ISO 712, Clause 1 a)</a>
243
- <a href="#ISO712">ISO 712, Clause 1</a>
244
- <a href="#ISO712">ISO 712, 1.5</a>
245
- <a href="#ISO712">A</a>
246
- <a href="#ISO712">ISO 712, Whole of text</a>
247
- <a href="#ISO712">ISO 712, Prelude 7</a>
248
- <a href="#ISO712">A</a>
249
- </p>
250
- </div>
251
- <p class="zzSTDTitle1"/>
252
- <div>
253
- <h1>1&#160; Normative references</h1>
254
- <p id="ISO712" class="NormRef">ISO 712, <i>Cereals and cereal products</i></p>
255
- </div>
256
- </div>
257
- </body>
258
- </html>
231
+ <?xml version='1.0'?>
232
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
233
+ <preface>
234
+ <foreword>
235
+ <p>
236
+ <eref type='inline' bibitemid='IEV' citeas='IEV'>
237
+ <locality type='clause'>
238
+ <referenceFrom>1-2-3</referenceFrom>
239
+ </locality>
240
+ IEV, 1-2-3
241
+ </eref>
242
+ <eref type='inline' bibitemid='ISO712' citeas='ISO 712'>ISO 712</eref>
243
+ <eref type='inline' bibitemid='ISO712'>ISO 712</eref>
244
+ <eref type='inline' bibitemid='ISO712'>
245
+ <locality type='table'>
246
+ <referenceFrom>1</referenceFrom>
247
+ </locality>
248
+ ISO 712, Table 1
249
+ </eref>
250
+ <eref type='inline' bibitemid='ISO712'>
251
+ <locality type='table'>
252
+ <referenceFrom>1</referenceFrom>
253
+ <referenceTo>1</referenceTo>
254
+ </locality>
255
+ ISO 712, Table 1&#x2013;1
256
+ </eref>
257
+ <eref type='inline' bibitemid='ISO712'>
258
+ <locality type='clause'>
259
+ <referenceFrom>1</referenceFrom>
260
+ </locality>
261
+ <locality type='table'>
262
+ <referenceFrom>1</referenceFrom>
263
+ </locality>
264
+ ISO 712, Clause 1, Table 1
265
+ </eref>
266
+ <eref type='inline' bibitemid='ISO712'>
267
+ <locality type='clause'>
268
+ <referenceFrom>1</referenceFrom>
269
+ </locality>
270
+ <locality type='list'>
271
+ <referenceFrom>a</referenceFrom>
272
+ </locality>
273
+ ISO 712, Clause 1 a)
274
+ </eref>
275
+ <eref type='inline' bibitemid='ISO712'>
276
+ <locality type='clause'>
277
+ <referenceFrom>1</referenceFrom>
278
+ </locality>
279
+ ISO 712, Clause 1
280
+ </eref>
281
+ <eref type='inline' bibitemid='ISO712'>
282
+ <locality type='clause'>
283
+ <referenceFrom>1.5</referenceFrom>
284
+ </locality>
285
+ ISO 712, 1.5
286
+ </eref>
287
+ <eref type='inline' bibitemid='ISO712'>
288
+ <locality type='table'>
289
+ <referenceFrom>1</referenceFrom>
290
+ </locality>
291
+ A
292
+ </eref>
293
+ <eref type='inline' bibitemid='ISO712'>
294
+ <locality type='whole'/>
295
+ ISO 712, Whole of text
296
+ </eref>
297
+ <eref type='inline' bibitemid='ISO712'>
298
+ <locality type='locality:prelude'>
299
+ <referenceFrom>7</referenceFrom>
300
+ </locality>
301
+ ISO 712, Prelude 7
302
+ </eref>
303
+ <eref type='inline' bibitemid='ISO712' citeas='ISO 712'>A</eref>
304
+ </p>
305
+ </foreword>
306
+ </preface>
307
+ <bibliography>
308
+ <references id='_normative_references' obligation='informative' normative='true'>
309
+ <title depth='1'>
310
+ 1
311
+ <tab/>
312
+ Normative References
313
+ </title>
314
+ <bibitem id='ISO712' type='standard'>
315
+ <title format='text/plain'>Cereals and cereal products</title>
316
+ <docidentifier>ISO 712</docidentifier>
317
+ <contributor>
318
+ <role type='publisher'/>
319
+ <organization>
320
+ <abbreviation>ISO</abbreviation>
321
+ </organization>
322
+ </contributor>
323
+ </bibitem>
324
+ </references>
325
+ </bibliography>
326
+ </iso-standard>
259
327
  OUTPUT
260
328
  end
261
329
 
@@ -92,11 +92,11 @@ RSpec.describe IsoDoc::Iso do
92
92
  <iso-standard xmlns="http://riboseinc.com/isoxml">
93
93
  <preface><foreword>
94
94
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
95
- <eref bibitemid="IEV"/>
96
- <eref bibitemid="ISO20483"/>
95
+ <eref bibitemid="IEV">IEV</eref>
96
+ <eref bibitemid="ISO20483">ISO 20483</eref>
97
97
  </p>
98
98
  </foreword></preface>
99
- <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
99
+ <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>1<tab/>Normative References</title>
100
100
  <bibitem type="international-standard" id="IEV">
101
101
  <title format="text/plain" language="en" script="Latn">Electropedia:
102
102
  The World's Online Electrotechnical Vocabulary</title>
@@ -153,8 +153,8 @@ RSpec.describe IsoDoc::Iso do
153
153
  </div>
154
154
  <p class="zzSTDTitle1"/>
155
155
  <div>
156
- <h1>1&#160; Normative references</h1>
157
- <p id="ISO20483" class="NormRef">ISO 20483, <i> Cereals and pulses</i></p>
156
+ <h1>1&#160; Normative References</h1>
157
+ <p id="ISO20483" class="NormRef">ISO 20483, <i>Cereals and pulses</i></p>
158
158
  </div>
159
159
  </div>
160
160
  </body>
@@ -163,8 +163,8 @@ RSpec.describe IsoDoc::Iso do
163
163
  OUTPUT
164
164
  end
165
165
 
166
- it "processes examples" do
167
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
166
+ it "processes examples (Presentation XML)" do
167
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
168
168
  <iso-standard xmlns="http://riboseinc.com/isoxml">
169
169
  <preface><foreword>
170
170
  <example id="samplecode">
@@ -173,6 +173,33 @@ end
173
173
  </example>
174
174
  </foreword></preface>
175
175
  </iso-standard>
176
+ INPUT
177
+ <?xml version='1.0'?>
178
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
179
+ <preface>
180
+ <foreword>
181
+ <example id='samplecode'>
182
+ <name>EXAMPLE&#xA0;&#x2014; Title</name>
183
+ <p>Hello</p>
184
+ </example>
185
+ </foreword>
186
+ </preface>
187
+ </iso-standard>
188
+ OUTPUT
189
+ end
190
+
191
+ it "processes examples (HTML)" do
192
+ expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
193
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
194
+ <preface>
195
+ <foreword>
196
+ <example id='samplecode'>
197
+ <name>EXAMPLE&#xA0;&#x2014; Title</name>
198
+ <p>Hello</p>
199
+ </example>
200
+ </foreword>
201
+ </preface>
202
+ </iso-standard>
176
203
  INPUT
177
204
  #{HTML_HDR}
178
205
  <br/>
@@ -189,9 +216,8 @@ end
189
216
  OUTPUT
190
217
  end
191
218
 
192
-
193
- it "processes sequences of examples" do
194
- expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
219
+ it "processes sequences of examples (Presentation XML)" do
220
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
195
221
  <iso-standard xmlns="http://riboseinc.com/isoxml">
196
222
  <preface><foreword>
197
223
  <example id="samplecode">
@@ -203,6 +229,41 @@ end
203
229
  </example>
204
230
  </foreword></preface>
205
231
  </iso-standard>
232
+ INPUT
233
+ <?xml version='1.0'?>
234
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
235
+ <preface>
236
+ <foreword>
237
+ <example id='samplecode'>
238
+ <name>EXAMPLE 1</name>
239
+ <quote>Hello</quote>
240
+ </example>
241
+ <example id='samplecode2'>
242
+ <name>EXAMPLE 2&#xA0;&#x2014; Title</name>
243
+ <p>Hello</p>
244
+ </example>
245
+ </foreword>
246
+ </preface>
247
+ </iso-standard>
248
+ OUTPUT
249
+ end
250
+
251
+ it "processes sequences of examples (HTML)" do
252
+ expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
253
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
254
+ <preface>
255
+ <foreword>
256
+ <example id='samplecode'>
257
+ <name>EXAMPLE 1</name>
258
+ <quote>Hello</quote>
259
+ </example>
260
+ <example id='samplecode2'>
261
+ <name>EXAMPLE 2&#xA0;&#x2014; Title</name>
262
+ <p>Hello</p>
263
+ </example>
264
+ </foreword>
265
+ </preface>
266
+ </iso-standard>
206
267
  INPUT
207
268
  #{HTML_HDR}
208
269
  <br/>
@@ -225,14 +286,16 @@ end
225
286
 
226
287
  it "processes examples (Word)" do
227
288
  expect(xmlpp(IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
228
- <iso-standard xmlns="http://riboseinc.com/isoxml">
229
- <preface><foreword>
230
- <example id="samplecode">
231
- <name>Title</name>
232
- <p>Hello</p>
233
- </example>
234
- </foreword></preface>
235
- </iso-standard>
289
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
290
+ <preface>
291
+ <foreword>
292
+ <example id='samplecode'>
293
+ <name>EXAMPLE&#xA0;&#x2014; Title</name>
294
+ <p>Hello</p>
295
+ </example>
296
+ </foreword>
297
+ </preface>
298
+ </iso-standard>
236
299
  INPUT
237
300
  <body lang="EN-US" link="blue" vlink="#954F72">
238
301
  <div class="WordSection1">
@@ -268,17 +331,20 @@ end
268
331
 
269
332
  it "processes sequences of examples (Word)" do
270
333
  expect(IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body").sub(%r{</body>.*$}m, "</body>")).to be_equivalent_to <<~"OUTPUT"
271
- <iso-standard xmlns="http://riboseinc.com/isoxml">
272
- <preface><foreword>
273
- <example id="samplecode">
274
- <quote>Hello</quote>
275
- </example>
276
- <example id="samplecode2">
277
- <name>Title</name>
278
- <p>Hello</p>
279
- </example>
280
- </foreword></preface>
281
- </iso-standard>
334
+ <iso-standard xmlns='http://riboseinc.com/isoxml'>
335
+ <preface>
336
+ <foreword>
337
+ <example id='samplecode'>
338
+ <name>EXAMPLE 1</name>
339
+ <quote>Hello</quote>
340
+ </example>
341
+ <example id='samplecode2'>
342
+ <name>EXAMPLE 2&#xA0;&#x2014; Title</name>
343
+ <p>Hello</p>
344
+ </example>
345
+ </foreword>
346
+ </preface>
347
+ </iso-standard>
282
348
  INPUT
283
349
  <body lang="EN-US" link="blue" vlink="#954F72">
284
350
  <div class="WordSection1">
@@ -2,6 +2,7 @@ require "spec_helper"
2
2
  require "fileutils"
3
3
 
4
4
  RSpec.describe IsoDoc do
5
+
5
6
  it "generates file based on string input" do
6
7
  FileUtils.rm_f "test.doc"
7
8
  FileUtils.rm_f "test.html"
@@ -105,10 +106,10 @@ RSpec.describe IsoDoc do
105
106
  <annex id="P" inline-header="false" obligation="normative">
106
107
  <title>Annex</title>
107
108
  <clause id="Q" inline-header="false" obligation="normative">
108
- <title>Annex A.1</title>
109
+ <title>A.1<tab/>Annex A.1</title>
109
110
  </clause>
110
111
  <appendix id="Q2" inline-header="false" obligation="normative">
111
- <title>An Appendix</title>
112
+ <title>Appendix 1<tab/>An Appendix</title>
112
113
  </appendix>
113
114
  </annex>
114
115
  </iso-standard>
@@ -120,7 +121,7 @@ RSpec.describe IsoDoc do
120
121
  <p class="zzSTDTitle1"></p>
121
122
  <p class="MsoNormal"><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
122
123
  <div class="Section3"><a name="P" id="P"></a>
123
- <h1 class="Annex"><b>Annex A</b><br/>(normative)<br/><br/><b>Annex</b></h1>
124
+ <h1 class="Annex">Annex</h1>
124
125
  <div><a name="Q" id="Q"></a>
125
126
  <p class="h2Annex">A.1<span style="mso-tab-count:1">&#xA0; </span>Annex A.1</p>
126
127
  </div>
@@ -138,12 +139,14 @@ RSpec.describe IsoDoc do
138
139
  IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
139
140
  <iso-standard xmlns="http://riboseinc.com/isoxml">
140
141
  <sections>
141
- <terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
142
+ <terms id="_terms_and_definitions" obligation="normative"><title>1<tab/>Terms and Definitions</title>
142
143
 
143
- <term id="paddy1"><preferred>paddy</preferred>
144
+ <term id="paddy1">
145
+ <name>1.1</name>
146
+ <preferred>paddy</preferred>
144
147
  <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
145
148
  <termsource status="modified">
146
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
149
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
147
150
  <modification>
148
151
  <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
149
152
  </modification>
@@ -190,14 +193,14 @@ RSpec.describe IsoDoc do
190
193
  IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
191
194
  <iso-standard xmlns="http://riboseinc.com/isoxml">
192
195
  <sections>
193
- <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
196
+ <clause id="A" inline-header="false" obligation="normative"><title>1<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
194
197
 
195
- <title>Introduction<bookmark id="Q"/> to this<fn reference="1">
198
+ <title>1.1<tab/>Introduction<bookmark id="Q"/> to this<fn reference="1">
196
199
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
197
200
  </fn></title>
198
201
  </clause>
199
202
  <clause id="O" inline-header="false" obligation="normative">
200
- <title>Clause 4.2</title>
203
+ <title>1.2<tab/>Clause 4.2</title>
201
204
  <p>A<fn reference="1">
202
205
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
203
206
  </fn></p>
@@ -263,21 +266,21 @@ RSpec.describe IsoDoc do
263
266
  OUTPUT
264
267
  end
265
268
 
266
- it "reorders footnote numbers in HTML" do
269
+ it "reorders footnote numbers" do
267
270
  FileUtils.rm_f "test.html"
268
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
271
+ input = <<~INPUT
269
272
  <iso-standard xmlns="http://riboseinc.com/isoxml">
270
273
  <sections>
271
- <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><fn reference="3">
274
+ <clause id="A" inline-header="false" obligation="normative"><title>1<tab/>Clause 4</title><fn reference="3">
272
275
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">This is a footnote.</p>
273
276
  </fn><clause id="N" inline-header="false" obligation="normative">
274
277
 
275
- <title>Introduction to this<fn reference="2">
278
+ <title>1.1<tab/>Introduction to this<fn reference="2">
276
279
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
277
280
  </fn></title>
278
281
  </clause>
279
282
  <clause id="O" inline-header="false" obligation="normative">
280
- <title>Clause 4.2</title>
283
+ <title>1.2<tab/>Clause 4.2</title>
281
284
  <p>A<fn reference="1">
282
285
  <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
283
286
  </fn></p>
@@ -285,6 +288,7 @@ RSpec.describe IsoDoc do
285
288
  </sections>
286
289
  </iso-standard>
287
290
  INPUT
291
+ IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", input, false)
288
292
  html = File.read("test.html", encoding: "UTF-8").sub(/^.*<main class="main-section">/m, '<main xmlns:epub="epub" class="main-section">').
289
293
  sub(%r{</main>.*$}m, "</main>")
290
294
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
@@ -315,30 +319,9 @@ RSpec.describe IsoDoc do
315
319
 
316
320
  </main>
317
321
  OUTPUT
318
- end
319
322
 
320
- it "renders footnote numbers in Word" do
321
323
  FileUtils.rm_f "test.doc"
322
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
323
- <iso-standard xmlns="http://riboseinc.com/isoxml">
324
- <sections>
325
- <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><fn reference="3">
326
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">This is a footnote.</p>
327
- </fn><clause id="N" inline-header="false" obligation="normative">
328
-
329
- <title>Introduction to this<fn reference="2">
330
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
331
- </fn></title>
332
- </clause>
333
- <clause id="O" inline-header="false" obligation="normative">
334
- <title>Clause 4.2</title>
335
- <p>A<fn reference="1">
336
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
337
- </fn></p>
338
- </clause></clause>
339
- </sections>
340
- </iso-standard>
341
- INPUT
324
+ IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", input, false)
342
325
  html = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3"/m, '<body xmlns:epub="epub"><div class="WordSection3"').
343
326
  sub(%r{</body>.*$}m, "</body>").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")
344
327
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
@@ -442,42 +425,6 @@ RSpec.describe IsoDoc do
442
425
  end
443
426
 
444
427
 
445
- it "moves images in HTML" do
446
- FileUtils.rm_f "test.html"
447
- FileUtils.rm_rf "_images"
448
- FileUtils.rm_rf "test_htmlimages"
449
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
450
- <iso-standard xmlns="http://riboseinc.com/isoxml">
451
- <preface><foreword>
452
- <figure id="_">
453
- <name>Split-it-right sample divider</name>
454
- <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/>
455
- <image src="spec/assets/rice_image1.png" id="_" width="20000" height="300000" mimetype="image/png"/>
456
- <image src="spec/assets/rice_image1.png" id="_" width="99" height="auto" mimetype="image/png"/>
457
- </figure>
458
- </foreword></preface>
459
- </iso-standard>
460
- INPUT
461
- html = File.read("test.html", encoding: "UTF-8").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
462
- sub(%r{</main>.*$}m, "</main>")
463
- expect(`ls test_htmlimages`).to match(/\.png$/)
464
- expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
465
- <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
466
- <br />
467
- <div>
468
- <h1 class="ForewordTitle" id="toc0">Foreword</h1>
469
- <div id="_" class="figure">
470
- <img src="test_htmlimages/_.png" height="776" width="922" />
471
- <img src="test_htmlimages/_.png" height="800" width="53" />
472
- <img src="test_htmlimages/_.png" height="83" width="99" />
473
- <p class="FigureTitle" style="text-align:center;">Figure 1&#xA0;&#x2014; Split-it-right sample divider</p></div>
474
- </div>
475
- <p class="zzSTDTitle1"></p>
476
- </main>
477
- OUTPUT
478
-
479
- end
480
-
481
428
  it "processes IsoXML terms for HTML" do
482
429
  FileUtils.rm_f "test.html"
483
430
  FileUtils.rm_f "test.doc"
@@ -486,7 +433,9 @@ RSpec.describe IsoDoc do
486
433
  <sections>
487
434
  <terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
488
435
 
489
- <term id="paddy1"><preferred>paddy</preferred>
436
+ <term id="paddy1">
437
+ <name>1.1</name>
438
+ <preferred>paddy</preferred>
490
439
  <domain>rice</domain>
491
440
  <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
492
441
  <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
@@ -508,7 +457,9 @@ RSpec.describe IsoDoc do
508
457
  </modification>
509
458
  </termsource></term>
510
459
 
511
- <term id="paddy"><preferred>paddy</preferred><admitted>paddy rice</admitted>
460
+ <term id="paddy">
461
+ <name>1.2</name>
462
+ <preferred>paddy</preferred><admitted>paddy rice</admitted>
512
463
  <admitted>rough rice</admitted>
513
464
  <deprecates>cargo rice</deprecates>
514
465
  <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
@@ -561,19 +512,11 @@ RSpec.describe IsoDoc do
561
512
  <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
562
513
  </p>
563
514
  <div class="Section3"><a name="P" id="P"></a>
564
- <h1 class='Annex'>
565
- <b>Annex A</b>
566
- <br/>
567
- (normative)
568
- <br/>
569
- <br/>
570
- <b/>
571
- </h1>
572
515
  <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851c" id="_63112cbc-cde0-435f-9553-e0b8c4f5851c"></a>
573
- <p class="example"><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#xA0; </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
516
+ <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
574
517
  </div>
575
518
  <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851d" id="_63112cbc-cde0-435f-9553-e0b8c4f5851d"></a>
576
- <p class="example"><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#xA0; </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
519
+ <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
577
520
  </div>
578
521
  </div>
579
522
  </div>
@@ -606,19 +549,11 @@ RSpec.describe IsoDoc do
606
549
  <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
607
550
  </p>
608
551
  <div class="Section3"><a name="P" id="P"></a>
609
- <h1 class='Annex'>
610
- <b>Annex A</b>
611
- <br/>
612
- (normative)
613
- <br/>
614
- <br/>
615
- <b/>
616
- </h1>
617
552
  <div class="figure"><a name="samplecode" id="samplecode"></a>
618
553
  <p class="MsoNormal">Hello</p>
619
554
  <p class="MsoNormal">Key</p>
620
555
  <p style='page-break-after:avoid;' class='MsoNormal'><b>Key</b></p><div class="figdl" style="page-break-after:avoid;"><table class="figdl"><tr><td valign="top" align="left"><p align="left" style="margin-left:0pt;text-align:left;" class="MsoNormal"><p class="MsoNormal">A</p></p></td><td valign="top"><p class="MsoNormal">B</p></td></tr></table></div>
621
- <p class="FigureTitle" style="text-align:center;">Figure A.1</p></div>
556
+ <p class="FigureTitle" style="text-align:center;"/></div>
622
557
  </div>
623
558
  </div>
624
559
 
@@ -626,9 +561,7 @@ RSpec.describe IsoDoc do
626
561
  end
627
562
 
628
563
  it "processes boilerplate" do
629
- FileUtils.rm_f "test.doc"
630
- FileUtils.rm_f "test.html"
631
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
564
+ input = <<~INPUT
632
565
  <iso-standard xmlns="http://riboseinc.com/isoxml">
633
566
  <bibdata type="standard">
634
567
  <status><stage>30</stage></status>
@@ -662,8 +595,7 @@ I am the Walrus.
662
595
  <clause>
663
596
  <title>Warning for Stuff</title>
664
597
 
665
- <p>This
666
- document is not an ISO International Standard. It is distributed for review and
598
+ <p>This document is not an ISO International Standard. It is distributed for review and
667
599
  comment. It is subject to change without notice and may not be referred to as
668
600
  an International Standard.</p>
669
601
 
@@ -677,67 +609,100 @@ documentation.</p>
677
609
  </boilerplate>
678
610
  </iso-standard>
679
611
  INPUT
680
- word = File.read("test.html", encoding: "UTF-8")
681
- expect((word)).to include '<h1 class="IntroTitle">Warning for Stuff</h1>'
682
- expect((word)).to include "I am the Walrus."
683
- end
684
612
 
685
- it "processes boilerplate (Word)" do
686
- FileUtils.rm_f "test.doc"
687
- FileUtils.rm_f "test.html"
688
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
689
- <iso-standard xmlns="http://riboseinc.com/isoxml">
690
- <bibdata type="standard">
691
- <status><stage>30</stage></status>
692
- </bibdata>
693
- <boilerplate>
694
- <copyright-statement>
695
- <clause>
696
- <p id="boilerplate-year">Published in Elbonia</p>
613
+ presxml = <<~OUTPUT
614
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
615
+ <bibdata type="standard">
616
+ <status><stage>30</stage></status>
617
+ </bibdata>
618
+ <boilerplate>
619
+ <copyright-statement>
620
+ <clause inline-header="true">
621
+ <p id="boilerplate-year">
622
+ &#xA9; ISO 2019, Published in Switzerland
623
+ </p>
624
+
625
+ <p id="boilerplate-message">
626
+ I am the Walrus.
627
+ </p>
628
+
629
+ <p id="boilerplate-name">ISO copyright office</p>
630
+ <p id="boilerplate-address" align="left">
631
+ ISO copyright office<br/>
632
+ Ch. de Blandonnet 8 ?~@? CP 401<br/>
633
+ CH-1214 Vernier, Geneva, Switzerland<br/>
634
+ Tel. + 41 22 749 01 11<br/>
635
+ Fax + 41 22 749 09 47<br/>
636
+ copyright@iso.org<br/>
637
+ www.iso.org
638
+ </p>
639
+ </clause>
640
+ </copyright-statement>
697
641
 
698
- <p id="boilerplate-message">No soup for you</p>
699
642
 
700
- <p id="boilerplate-place">Dilbert Associates</p>
701
- <p id="boilerplate-address" align="left">Elbonia 5000</p>
702
- </clause>
703
- </copyright-statement>
643
+ <license-statement>
644
+ <clause>
645
+ <title depth="1">Warning for Stuff</title>
704
646
 
647
+ <p>This document is not an ISO International Standard. It is distributed for review and
648
+ comment. It is subject to change without notice and may not be referred to as
649
+ an International Standard.</p>
705
650
 
706
- <license-statement>
707
- <clause>
708
- <title>Warning for Stuff</title>
651
+ <p>Recipients
652
+ of this draft are invited to submit, with their comments, notification of any
653
+ relevant patent rights of which they are aware and to provide supporting
654
+ documentation.</p>
655
+ </clause>
656
+ </license-statement>
709
657
 
710
- <p>I am the Walrus</p>
711
- </clause>
712
- </license-statement>
658
+ </boilerplate>
659
+ </iso-standard>
660
+ OUTPUT
713
661
 
714
- </boilerplate>
715
- </iso-standard>
716
- INPUT
662
+ FileUtils.rm_f "test.doc"
663
+ FileUtils.rm_f "test.html"
664
+ expect((IsoDoc::Iso::PresentationXMLConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
665
+ IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", presxml, false)
666
+ word = File.read("test.html", encoding: "UTF-8")
667
+ expect((word)).to include '<h1 class="IntroTitle">Warning for Stuff</h1>'
668
+ expect((word)).to include "I am the Walrus."
669
+ IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", presxml, false)
717
670
  word = File.read("test.doc", encoding: "UTF-8")
718
671
  expect(xmlpp(word.sub(%r{^.*<div class="boilerplate-copyright">}m, '<div class="boilerplate-copyright">').sub(%r{</div>.*$}m, '</div></div>'))).to be_equivalent_to xmlpp(<<~"OUTPUT")
719
- <div class='boilerplate-copyright'>
720
- <div>
721
- <p class='zzCopyright'>
722
- <a name='boilerplate-year' id='boilerplate-year'/>
723
- <span><b/></span>Published in Elbonia
724
- </p>
725
- <p class='zzCopyright1'>
726
- <a name='boilerplate-message' id='boilerplate-message'/>
727
- No soup for you
728
- </p>
729
- <p class='zzCopyright1'>
730
- <a name='boilerplate-place' id='boilerplate-place'/>
731
- Dilbert Associates
732
- </p>
733
- <p align='left' style='text-align:left;' class='zzAddress'>
734
- <a name='boilerplate-address' id='boilerplate-address'/>
735
- Elbonia 5000
736
- </p>
737
- </div>
738
- </div>
672
+ <div class='boilerplate-copyright'>
673
+ <div>
674
+ <p class='zzCopyright'>
675
+ <a name='boilerplate-year' id='boilerplate-year'/>
676
+ &#xA9; ISO 2019, Published in Switzerland
677
+ </p>
678
+ <p class='zzCopyright1'>
679
+ <a name='boilerplate-message' id='boilerplate-message'/>
680
+ I am the Walrus.
681
+ </p>
682
+ <p class='zzCopyright'>
683
+ <a name='boilerplate-name' id='boilerplate-name'/>
684
+ ISO copyright office
685
+ </p>
686
+ <p style='text-align:left;' align='left' class='zzAddress'>
687
+ <a name='boilerplate-address' id='boilerplate-address'/>
688
+ ISO copyright office
689
+ <br/>
690
+ Ch. de Blandonnet 8 ?~@? CP 401
691
+ <br/>
692
+ CH-1214 Vernier, Geneva, Switzerland
693
+ <br/>
694
+ Tel. + 41 22 749 01 11
695
+ <br/>
696
+ Fax + 41 22 749 09 47
697
+ <br/>
698
+ copyright@iso.org
699
+ <br/>
700
+ www.iso.org
701
+ </p>
702
+ </div>
703
+ </div>
739
704
  OUTPUT
740
- expect(word).to include '<p class="zzWarning">I am the Walrus</p>'
705
+ expect(word).to include '<p class="zzWarning">This document is not an ISO International Standard'
741
706
  end
742
707
 
743
708
  end