metanorma-iso 1.7.0 → 1.8.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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +11 -41
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +6 -2
  5. data/lib/asciidoctor/iso/base.rb +12 -12
  6. data/lib/asciidoctor/iso/biblio.rng +4 -6
  7. data/lib/asciidoctor/iso/cleanup.rb +1 -1
  8. data/lib/asciidoctor/iso/front.rb +1 -1
  9. data/lib/asciidoctor/iso/front_id.rb +30 -25
  10. data/lib/asciidoctor/iso/isodoc.rng +235 -3
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
  12. data/lib/asciidoctor/iso/isostandard.rng +17 -97
  13. data/lib/asciidoctor/iso/validate.rb +1 -0
  14. data/lib/asciidoctor/iso/validate_title.rb +21 -13
  15. data/lib/isodoc/iso/base_convert.rb +11 -0
  16. data/lib/isodoc/iso/html/style-human.css +7 -0
  17. data/lib/isodoc/iso/html/style-iso.css +7 -0
  18. data/lib/isodoc/iso/html_convert.rb +0 -1
  19. data/lib/isodoc/iso/i18n-en.yaml +4 -0
  20. data/lib/isodoc/iso/i18n-fr.yaml +4 -0
  21. data/lib/isodoc/iso/i18n-zh-Hans.yaml +4 -0
  22. data/lib/isodoc/iso/index.rb +140 -0
  23. data/lib/isodoc/iso/iso.amendment.xsl +1010 -324
  24. data/lib/isodoc/iso/iso.international-standard.xsl +1010 -324
  25. data/lib/isodoc/iso/presentation_xml_convert.rb +32 -25
  26. data/lib/isodoc/iso/word_convert.rb +0 -1
  27. data/lib/isodoc/iso/xref.rb +13 -5
  28. data/lib/metanorma/iso/version.rb +1 -1
  29. data/metanorma-iso.gemspec +8 -8
  30. data/spec/asciidoctor/amd_spec.rb +696 -0
  31. data/spec/asciidoctor/base_spec.rb +704 -0
  32. data/spec/asciidoctor/blocks_spec.rb +527 -0
  33. data/spec/asciidoctor/cleanup_spec.rb +1134 -0
  34. data/spec/asciidoctor/inline_spec.rb +195 -0
  35. data/spec/asciidoctor/lists_spec.rb +197 -0
  36. data/spec/asciidoctor/refs_spec.rb +375 -0
  37. data/spec/asciidoctor/section_spec.rb +393 -0
  38. data/spec/asciidoctor/table_spec.rb +329 -0
  39. data/spec/asciidoctor/validate_spec.rb +1572 -0
  40. data/spec/isodoc/amd_spec.rb +967 -946
  41. data/spec/isodoc/blocks_spec.rb +530 -507
  42. data/spec/isodoc/i18n_spec.rb +953 -911
  43. data/spec/isodoc/inline_spec.rb +355 -293
  44. data/spec/isodoc/iso_spec.rb +338 -314
  45. data/spec/isodoc/metadata_spec.rb +392 -382
  46. data/spec/isodoc/postproc_spec.rb +837 -657
  47. data/spec/isodoc/ref_spec.rb +374 -331
  48. data/spec/isodoc/section_spec.rb +821 -519
  49. data/spec/isodoc/table_spec.rb +472 -411
  50. data/spec/isodoc/terms_spec.rb +209 -185
  51. data/spec/isodoc/xref_spec.rb +1370 -1236
  52. data/spec/metanorma/processor_spec.rb +28 -26
  53. data/spec/spec_helper.rb +186 -189
  54. metadata +65 -67
  55. data/.rubocop.ribose.yml +0 -66
  56. data/lib/isodoc/iso/html/scripts.html +0 -178
  57. data/spec/asciidoctor-iso/amd_spec.rb +0 -694
  58. data/spec/asciidoctor-iso/base_spec.rb +0 -713
  59. data/spec/asciidoctor-iso/blocks_spec.rb +0 -482
  60. data/spec/asciidoctor-iso/cleanup_spec.rb +0 -1025
  61. data/spec/asciidoctor-iso/inline_spec.rb +0 -170
  62. data/spec/asciidoctor-iso/lists_spec.rb +0 -190
  63. data/spec/asciidoctor-iso/refs_spec.rb +0 -317
  64. data/spec/asciidoctor-iso/section_spec.rb +0 -362
  65. data/spec/asciidoctor-iso/table_spec.rb +0 -313
  66. data/spec/asciidoctor-iso/validate_spec.rb +0 -1619
  67. data/spec/assets/xref_error.adoc +0 -7
@@ -1,482 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Asciidoctor::ISO do
4
- it "processes open blocks" do
5
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
- #{ASCIIDOC_BLANK_HDR}
7
- --
8
- x
9
-
10
- y
11
-
12
- z
13
- --
14
- INPUT
15
- #{BLANK_HDR}
16
- <sections><p id="_">x</p>
17
- <p id="_">y</p>
18
- <p id="_">z</p></sections>
19
- </iso-standard>
20
- OUTPUT
21
- end
22
-
23
- it "processes stem blocks" do
24
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
25
- #{ASCIIDOC_BLANK_HDR}
26
- [stem]
27
- ++++
28
- r = 1 %
29
- r = 1 %
30
- ++++
31
-
32
- [stem]
33
- ++++
34
- <mml:math><mml:msub xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"> <mml:mrow> <mml:mrow> <mml:mi mathvariant="bold-italic">F</mml:mi> </mml:mrow> </mml:mrow> <mml:mrow> <mml:mrow> <mml:mi mathvariant="bold-italic">&#x0391;</mml:mi> </mml:mrow> </mml:mrow> </mml:msub> </mml:math>
35
- ++++
36
- INPUT
37
- #{BLANK_HDR}
38
- <sections>
39
- <formula id="_">
40
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem>
41
- </formula>
42
-
43
- <formula id="_">
44
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub> <mrow> <mrow> <mi mathvariant="bold-italic">F</mi> </mrow> </mrow> <mrow> <mrow> <mi mathvariant="bold-italic">Α</mi> </mrow> </mrow> </msub> </math></stem>
45
- </formula>
46
- </sections>
47
- </iso-standard>
48
- OUTPUT
49
- end
50
-
51
- it "ignores review blocks unless document is in draft mode" do
52
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
53
- #{ASCIIDOC_BLANK_HDR}
54
- [[foreword]]
55
- .Foreword
56
- Foreword
57
-
58
- [reviewer=ISO,date=20170101,from=foreword,to=foreword]
59
- ****
60
- A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.
61
-
62
- For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
63
- ****
64
- INPUT
65
- #{BLANK_HDR}
66
- <sections><p id="foreword">Foreword</p>
67
- </sections>
68
- </iso-standard>
69
- OUTPUT
70
- end
71
-
72
- it "processes review blocks if document is in draft mode" do
73
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)).sub(/^.+<sections>/m, "<iso-standard><sections>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
74
- = Document title
75
- Author
76
- :docfile: test.adoc
77
- :nodoc:
78
- :novalid:
79
- :draft: 1.2
80
- :no-isobib:
81
-
82
- [[foreword]]
83
- .Foreword
84
- Foreword
85
-
86
- [reviewer=ISO,date=20170101,from=foreword,to=foreword]
87
- ****
88
- A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.
89
-
90
- For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
91
- ****
92
- INPUT
93
- <iso-standard><sections>
94
- <p id="foreword">Foreword</p>
95
- <review reviewer="ISO" id="_" date="20170101T00:00:00Z" from="foreword" to="foreword"><p id="_">A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.</p>
96
- <p id="_">For further information on the Foreword, see <strong>ISO/IEC Directives, Part 2, 2016, Clause 12.</strong></p></review></sections>
97
- </iso-standard>
98
-
99
- OUTPUT
100
- end
101
-
102
- it "processes term notes" do
103
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
104
- #{ASCIIDOC_BLANK_HDR}
105
- == Terms and Definitions
106
-
107
- === Term1
108
-
109
- NOTE: This is a note
110
- INPUT
111
- #{BLANK_HDR}
112
- <sections>
113
- <terms id="_" obligation="normative">
114
- <title>Terms and definitions</title>
115
- #{TERM_BOILERPLATE}
116
- <term id="term-term1">
117
- <preferred>Term1</preferred>
118
- <termnote id="_">
119
- <p id="_">This is a note</p>
120
- </termnote>
121
- </term>
122
- </terms>
123
- </sections>
124
- </iso-standard>
125
- OUTPUT
126
- end
127
-
128
- it "processes notes" do
129
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
130
- #{ASCIIDOC_BLANK_HDR}
131
- NOTE: This is a note
132
- INPUT
133
- #{BLANK_HDR}
134
- <sections>
135
- <note id="_">
136
- <p id="_">This is a note</p>
137
- </note>
138
- </sections>
139
- </iso-standard>
140
-
141
- OUTPUT
142
- end
143
-
144
- it "processes literals" do
145
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
146
- #{ASCIIDOC_BLANK_HDR}
147
- ....
148
- LITERAL
149
- ....
150
- INPUT
151
- #{BLANK_HDR}
152
- <sections>
153
- <figure id="_">
154
- <pre id="_">LITERAL</pre>
155
- </figure>
156
- </sections>
157
- </iso-standard>
158
- OUTPUT
159
- end
160
-
161
- it "processes simple admonitions with Asciidoc names" do
162
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
163
- #{ASCIIDOC_BLANK_HDR}
164
- CAUTION: Only use paddy or parboiled rice for the determination of husked rice yield.
165
- INPUT
166
- #{BLANK_HDR}
167
- <sections>
168
- <admonition id="_" type="caution">
169
- <p id="_">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
170
- </admonition>
171
- </sections>
172
- </iso-standard>
173
-
174
- OUTPUT
175
- end
176
-
177
-
178
- it "processes complex admonitions with non-Asciidoc names" do
179
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
180
- #{ASCIIDOC_BLANK_HDR}
181
- [CAUTION,type=Safety Precautions]
182
- .Safety Precautions
183
- ====
184
- While werewolves are hardy community members, keep in mind the following dietary concerns:
185
-
186
- . They are allergic to cinnamon.
187
- . More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens.
188
- . Celery makes them sad.
189
- ====
190
- INPUT
191
- #{BLANK_HDR}
192
- <sections>
193
- <admonition id="_" type="safety precautions"><name>Safety Precautions</name><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
194
- <ol id="_">
195
- <li>
196
- <p id="_">They are allergic to cinnamon.</p>
197
- </li>
198
- <li>
199
- <p id="_">More than two glasses of orange juice in 24 hours makes them howl in harmony with alarms and sirens.</p>
200
- </li>
201
- <li>
202
- <p id="_">Celery makes them sad.</p>
203
- </li>
204
- </ol></admonition>
205
- </sections>
206
- </iso-standard>
207
-
208
- OUTPUT
209
- end
210
-
211
- it "processes term examples" do
212
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
213
- #{ASCIIDOC_BLANK_HDR}
214
- == Terms and Definitions
215
-
216
- === Term1
217
-
218
- [example]
219
- This is an example
220
- INPUT
221
- #{BLANK_HDR}
222
- <sections>
223
- <terms id="_" obligation="normative">
224
- <title>Terms and definitions</title>
225
- #{TERM_BOILERPLATE}
226
- <term id="term-term1">
227
- <preferred>Term1</preferred>
228
- <termexample id="_">
229
- <p id="_">This is an example</p>
230
- </termexample>
231
- </term>
232
- </terms>
233
- </sections>
234
- </iso-standard>
235
-
236
- OUTPUT
237
- end
238
-
239
- it "processes examples" do
240
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
241
- #{ASCIIDOC_BLANK_HDR}
242
- [example]
243
- ====
244
- This is an example
245
-
246
- Amen
247
- ====
248
- INPUT
249
- #{BLANK_HDR}
250
- <sections>
251
- <example id="_"><p id="_">This is an example</p>
252
- <p id="_">Amen</p></example>
253
- </sections>
254
- </iso-standard>
255
- OUTPUT
256
- end
257
-
258
- it "processes preambles" do
259
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
260
- #{ASCIIDOC_BLANK_HDR}
261
- This is a preamble
262
-
263
- == Section 1
264
- INPUT
265
- #{BLANK_HDR}
266
- <preface><foreword id="_" obligation="informative">
267
- <title>Foreword</title>
268
- <p id="_">This is a preamble</p>
269
- </foreword></preface><sections>
270
- <clause id="_" inline-header="false" obligation="normative">
271
- <title>Section 1</title>
272
- </clause></sections>
273
- </iso-standard>
274
- OUTPUT
275
- end
276
-
277
- it "processes images" do
278
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
279
- #{ASCIIDOC_BLANK_HDR}
280
- .Split-it-right sample divider
281
- image::spec/examples/rice_images/rice_image1.png[]
282
-
283
- INPUT
284
- #{BLANK_HDR}
285
- <sections>
286
- <figure id="_">
287
- <name>Split-it-right sample divider</name>
288
- <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
289
- </figure>
290
- </sections>
291
- </iso-standard>
292
- OUTPUT
293
- end
294
-
295
- it "accepts width and height attributes on images" do
296
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
297
- #{ASCIIDOC_BLANK_HDR}
298
- [height=4,width=3]
299
- image::spec/examples/rice_images/rice_image1.png[]
300
-
301
- INPUT
302
- #{BLANK_HDR}
303
- <sections>
304
- <figure id="_">
305
- <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="3"/>
306
- </figure>
307
- </sections>
308
- </iso-standard>
309
- OUTPUT
310
- end
311
-
312
- it "accepts auto for width and height attributes on images" do
313
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
314
- #{ASCIIDOC_BLANK_HDR}
315
- [height=4,width=auto]
316
- image::spec/examples/rice_images/rice_image1.png[]
317
-
318
- INPUT
319
- #{BLANK_HDR}
320
- <sections>
321
- <figure id="_">
322
- <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="auto"/>
323
- </figure>
324
- </sections>
325
- </iso-standard>
326
- OUTPUT
327
- end
328
-
329
- it "accepts alignment attribute on paragraphs" do
330
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
331
- #{ASCIIDOC_BLANK_HDR}
332
- [align=right]
333
- This para is right-aligned.
334
- INPUT
335
- #{BLANK_HDR}
336
- <sections>
337
- <p align="right" id="_">This para is right-aligned.</p>
338
- </sections>
339
- </iso-standard>
340
- OUTPUT
341
- end
342
-
343
- it "processes blockquotes" do
344
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
345
- #{ASCIIDOC_BLANK_HDR}
346
- [quote, ISO, "ISO7301,section 1"]
347
- ____
348
- Block quotation
349
- ____
350
- INPUT
351
- #{BLANK_HDR}
352
- <sections>
353
- <quote id="_">
354
- <source type="inline" bibitemid="ISO7301" citeas="">
355
- <localityStack>
356
- <locality type="section"><referenceFrom>1</referenceFrom></locality>
357
- </localityStack>
358
- </source>
359
- <author>ISO</author>
360
- <p id="_">Block quotation</p>
361
- </quote>
362
- </sections>
363
- </iso-standard>
364
- OUTPUT
365
- end
366
-
367
- it "processes source code" do
368
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
369
- #{ASCIIDOC_BLANK_HDR}
370
- [source,ruby]
371
- --
372
- puts "Hello, world."
373
- %w{a b c}.each do |x|
374
- puts x
375
- end
376
- --
377
- INPUT
378
- #{BLANK_HDR}
379
- <sections>
380
- <sourcecode lang="ruby" id="_">puts "Hello, world."
381
- %w{a b c}.each do |x|
382
- puts x
383
- end</sourcecode>
384
- </sections>
385
- </iso-standard>
386
- OUTPUT
387
- end
388
-
389
- it "processes callouts" do
390
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
391
- #{ASCIIDOC_BLANK_HDR}
392
- [source,ruby]
393
- --
394
- puts "Hello, world." <1>
395
- %w{a b c}.each do |x|
396
- puts x <2>
397
- end
398
- --
399
- <1> This is one callout
400
- <2> This is another callout
401
- INPUT
402
- #{BLANK_HDR}
403
- <sections><sourcecode lang="ruby" id="_">puts "Hello, world." <callout target="_">1</callout>
404
- %w{a b c}.each do |x|
405
- puts x <callout target="_">2</callout>
406
- end<annotation id="_">
407
- <p id="_">This is one callout</p>
408
- </annotation><annotation id="_">
409
- <p id="_">This is another callout</p>
410
- </annotation></sourcecode>
411
- </sections>
412
- </iso-standard>
413
- OUTPUT
414
- end
415
-
416
- it "processes unmodified term sources" do
417
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
418
- #{ASCIIDOC_BLANK_HDR}
419
- == Terms and Definitions
420
-
421
- === Term1
422
-
423
- [.source]
424
- <<ISO2191,section=1>>
425
- INPUT
426
- #{BLANK_HDR}
427
- <sections>
428
- <terms id="_" obligation="normative">
429
- <title>Terms and definitions</title>
430
- #{TERM_BOILERPLATE}
431
- <term id="term-term1">
432
- <preferred>Term1</preferred>
433
- <termsource status="identical">
434
- <origin bibitemid="ISO2191" type="inline" citeas="">
435
- <localityStack>
436
- <locality type="section"><referenceFrom>1</referenceFrom></locality>
437
- </localityStack>
438
- </origin>
439
- </termsource>
440
- </term>
441
- </terms>
442
- </sections>
443
- </iso-standard>
444
- OUTPUT
445
- end
446
-
447
- it "processes modified term sources" do
448
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
449
- #{ASCIIDOC_BLANK_HDR}
450
- == Terms and Definitions
451
-
452
- === Term1
453
-
454
- [.source]
455
- <<ISO2191,section=1>>, with adjustments
456
- INPUT
457
- #{BLANK_HDR}
458
- <sections>
459
- <terms id="_" obligation="normative">
460
- <title>Terms and definitions</title>
461
- #{TERM_BOILERPLATE}
462
- <term id="term-term1">
463
- <preferred>Term1</preferred>
464
- <termsource status="modified">
465
- <origin bibitemid="ISO2191" type="inline" citeas="">
466
- <localityStack>
467
- <locality type="section"><referenceFrom>1</referenceFrom></locality>
468
- </localityStack>
469
- </origin>
470
- <modification>
471
- <p id="_">with adjustments</p>
472
- </modification>
473
- </termsource>
474
- </term>
475
- </terms>
476
- </sections>
477
- </iso-standard>
478
- OUTPUT
479
- end
480
-
481
-
482
- end