metanorma-iso 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/asciidoctor/iso/biblio.rng +1 -0
- data/lib/asciidoctor/iso/isodoc.rng +1 -3
- data/lib/asciidoctor/iso/validate_section.rb +16 -9
- data/lib/isodoc/iso/iso.amendment.xsl +166 -111
- data/lib/isodoc/iso/iso.international-standard.xsl +166 -111
- data/lib/isodoc/iso/xref.rb +3 -2
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +1 -1
- data/spec/asciidoctor/blocks_spec.rb +96 -34
- data/spec/asciidoctor/validate_spec.rb +47 -0
- data/spec/spec_helper.rb +16 -15
- metadata +4 -4
data/lib/isodoc/iso/xref.rb
CHANGED
@@ -30,8 +30,9 @@ module IsoDoc
|
|
30
30
|
def introduction_names(clause)
|
31
31
|
return if clause.nil?
|
32
32
|
|
33
|
-
clause.at(ns("./clause")) and
|
34
|
-
{ label: "0", level: 1,
|
33
|
+
clause.at(ns("./clause")) and
|
34
|
+
@anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
|
35
|
+
xref: clause.at(ns("./title"))&.text }
|
35
36
|
i = Counter.new
|
36
37
|
clause.xpath(ns("./clause")).each do |c|
|
37
38
|
i.increment(c)
|
data/metanorma-iso.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.add_dependency "isodoc", "~> 1.6.2"
|
33
33
|
spec.add_dependency "metanorma-standoc", "~> 1.9.0"
|
34
|
-
spec.add_dependency "mn2sts", "~> 1.
|
34
|
+
spec.add_dependency "mn2sts", "~> 1.8.0"
|
35
35
|
spec.add_dependency "ruby-jing"
|
36
36
|
spec.add_dependency "tokenizer", "~> 0.3.0"
|
37
37
|
spec.add_dependency "twitter_cldr"
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe Asciidoctor::ISO do
|
4
4
|
it "processes open blocks" do
|
5
|
-
|
5
|
+
input = <<~INPUT
|
6
6
|
#{ASCIIDOC_BLANK_HDR}
|
7
7
|
--
|
8
8
|
x
|
@@ -12,6 +12,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
12
12
|
z
|
13
13
|
--
|
14
14
|
INPUT
|
15
|
+
output = <<~OUTPUT
|
15
16
|
#{BLANK_HDR}
|
16
17
|
<sections>
|
17
18
|
<p id="_">x</p>
|
@@ -20,10 +21,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
20
21
|
</sections>
|
21
22
|
</iso-standard>
|
22
23
|
OUTPUT
|
24
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
25
|
+
.to be_equivalent_to xmlpp(output)
|
23
26
|
end
|
24
27
|
|
25
28
|
it "processes stem blocks" do
|
26
|
-
|
29
|
+
input = <<~INPUT
|
27
30
|
#{ASCIIDOC_BLANK_HDR}
|
28
31
|
[stem]
|
29
32
|
++++
|
@@ -36,6 +39,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
36
39
|
<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">Α</mml:mi> </mml:mrow> </mml:mrow> </mml:msub> </mml:math>
|
37
40
|
++++
|
38
41
|
INPUT
|
42
|
+
output = <<~OUTPUT
|
39
43
|
#{BLANK_HDR}
|
40
44
|
<sections>
|
41
45
|
<formula id="_">
|
@@ -73,10 +77,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
73
77
|
</sections>
|
74
78
|
</iso-standard>
|
75
79
|
OUTPUT
|
80
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
81
|
+
.to be_equivalent_to xmlpp(output)
|
76
82
|
end
|
77
83
|
|
78
84
|
it "ignores review blocks unless document is in draft mode" do
|
79
|
-
|
85
|
+
input = <<~INPUT
|
80
86
|
#{ASCIIDOC_BLANK_HDR}
|
81
87
|
[[foreword]]
|
82
88
|
.Foreword
|
@@ -89,16 +95,19 @@ RSpec.describe Asciidoctor::ISO do
|
|
89
95
|
For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
|
90
96
|
****
|
91
97
|
INPUT
|
98
|
+
output = <<~OUTPUT
|
92
99
|
#{BLANK_HDR}
|
93
100
|
<sections>
|
94
101
|
<p id="foreword">Foreword</p>
|
95
102
|
</sections>
|
96
103
|
</iso-standard>
|
97
104
|
OUTPUT
|
105
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
106
|
+
.to be_equivalent_to xmlpp(output)
|
98
107
|
end
|
99
108
|
|
100
109
|
it "processes review blocks if document is in draft mode" do
|
101
|
-
|
110
|
+
input = Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
102
111
|
= Document title
|
103
112
|
Author
|
104
113
|
:docfile: test.adoc
|
@@ -118,23 +127,25 @@ RSpec.describe Asciidoctor::ISO do
|
|
118
127
|
For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
|
119
128
|
****
|
120
129
|
INPUT
|
121
|
-
|
122
|
-
|
123
|
-
<
|
124
|
-
<
|
125
|
-
|
126
|
-
<
|
127
|
-
|
128
|
-
<
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
output = <<~OUTPUT
|
131
|
+
<iso-standard>
|
132
|
+
<sections>
|
133
|
+
<p id="foreword">Foreword</p>
|
134
|
+
<review date="20170101T00:00:00Z" from="foreword" id="_" reviewer="ISO" to="foreword">
|
135
|
+
<p id="_">A Foreword shall appear in each document. The generic text is shown here. It does not contain requirements, recommendations or permissions.</p>
|
136
|
+
<p id="_">For further information on the Foreword, see#{' '}
|
137
|
+
<strong>ISO/IEC Directives, Part 2, 2016, Clause 12.</strong></p>
|
138
|
+
</review>
|
139
|
+
</sections>
|
140
|
+
</iso-standard>
|
141
|
+
OUTPUT
|
142
|
+
expect(xmlpp(strip_guid(input)
|
143
|
+
.sub(/^.+<sections>/m, "<iso-standard><sections>")))
|
144
|
+
.to be_equivalent_to xmlpp(output)
|
134
145
|
end
|
135
146
|
|
136
147
|
it "processes term notes" do
|
137
|
-
|
148
|
+
input = <<~INPUT
|
138
149
|
#{ASCIIDOC_BLANK_HDR}
|
139
150
|
== Terms and Definitions
|
140
151
|
|
@@ -142,6 +153,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
142
153
|
|
143
154
|
NOTE: This is a note
|
144
155
|
INPUT
|
156
|
+
output = <<~OUTPUT
|
145
157
|
#{BLANK_HDR}
|
146
158
|
<sections>
|
147
159
|
<terms id="_" obligation="normative">
|
@@ -156,13 +168,16 @@ RSpec.describe Asciidoctor::ISO do
|
|
156
168
|
</sections>
|
157
169
|
</iso-standard>
|
158
170
|
OUTPUT
|
171
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
172
|
+
.to be_equivalent_to xmlpp(output)
|
159
173
|
end
|
160
174
|
|
161
175
|
it "processes notes" do
|
162
|
-
|
176
|
+
input = <<~INPUT
|
163
177
|
#{ASCIIDOC_BLANK_HDR}
|
164
178
|
NOTE: This is a note
|
165
179
|
INPUT
|
180
|
+
output = <<~OUTPUT
|
166
181
|
#{BLANK_HDR}
|
167
182
|
<sections>
|
168
183
|
<note id="_">
|
@@ -171,15 +186,18 @@ RSpec.describe Asciidoctor::ISO do
|
|
171
186
|
</sections>
|
172
187
|
</iso-standard>
|
173
188
|
OUTPUT
|
189
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
190
|
+
.to be_equivalent_to xmlpp(output)
|
174
191
|
end
|
175
192
|
|
176
193
|
it "processes literals" do
|
177
|
-
|
194
|
+
input = <<~INPUT
|
178
195
|
#{ASCIIDOC_BLANK_HDR}
|
179
196
|
....
|
180
197
|
LITERAL
|
181
198
|
....
|
182
199
|
INPUT
|
200
|
+
output = <<~OUTPUT
|
183
201
|
#{BLANK_HDR}
|
184
202
|
<sections>
|
185
203
|
<figure id="_">
|
@@ -188,13 +206,16 @@ RSpec.describe Asciidoctor::ISO do
|
|
188
206
|
</sections>
|
189
207
|
</iso-standard>
|
190
208
|
OUTPUT
|
209
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
210
|
+
.to be_equivalent_to xmlpp(output)
|
191
211
|
end
|
192
212
|
|
193
213
|
it "processes simple admonitions with Asciidoc names" do
|
194
|
-
|
214
|
+
input = <<~INPUT
|
195
215
|
#{ASCIIDOC_BLANK_HDR}
|
196
216
|
CAUTION: Only use paddy or parboiled rice for the determination of husked rice yield.
|
197
217
|
INPUT
|
218
|
+
output = <<~OUTPUT
|
198
219
|
#{BLANK_HDR}
|
199
220
|
<sections>
|
200
221
|
<admonition id="_" type="caution">
|
@@ -203,10 +224,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
203
224
|
</sections>
|
204
225
|
</iso-standard>
|
205
226
|
OUTPUT
|
227
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
228
|
+
.to be_equivalent_to xmlpp(output)
|
206
229
|
end
|
207
230
|
|
208
231
|
it "processes complex admonitions with non-Asciidoc names" do
|
209
|
-
|
232
|
+
input = <<~INPUT
|
210
233
|
#{ASCIIDOC_BLANK_HDR}
|
211
234
|
[CAUTION,type=Safety Precautions]
|
212
235
|
.Safety Precautions
|
@@ -218,6 +241,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
218
241
|
. Celery makes them sad.
|
219
242
|
====
|
220
243
|
INPUT
|
244
|
+
output = <<~OUTPUT
|
221
245
|
#{BLANK_HDR}
|
222
246
|
<sections>
|
223
247
|
<admonition id="_" type="safety precautions">
|
@@ -238,10 +262,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
238
262
|
</sections>
|
239
263
|
</iso-standard>
|
240
264
|
OUTPUT
|
265
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
266
|
+
.to be_equivalent_to xmlpp(output)
|
241
267
|
end
|
242
268
|
|
243
269
|
it "processes term examples" do
|
244
|
-
|
270
|
+
input = <<~INPUT
|
245
271
|
#{ASCIIDOC_BLANK_HDR}
|
246
272
|
== Terms and Definitions
|
247
273
|
|
@@ -250,6 +276,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
250
276
|
[example]
|
251
277
|
This is an example
|
252
278
|
INPUT
|
279
|
+
output = <<~OUTPUT
|
253
280
|
#{BLANK_HDR}
|
254
281
|
<sections>
|
255
282
|
<terms id="_" obligation="normative">
|
@@ -264,10 +291,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
264
291
|
</sections>
|
265
292
|
</iso-standard>
|
266
293
|
OUTPUT
|
294
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
295
|
+
.to be_equivalent_to xmlpp(output)
|
267
296
|
end
|
268
297
|
|
269
298
|
it "processes examples" do
|
270
|
-
|
299
|
+
input = <<~INPUT
|
271
300
|
#{ASCIIDOC_BLANK_HDR}
|
272
301
|
[example]
|
273
302
|
====
|
@@ -276,6 +305,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
276
305
|
Amen
|
277
306
|
====
|
278
307
|
INPUT
|
308
|
+
output = <<~OUTPUT
|
279
309
|
#{BLANK_HDR}
|
280
310
|
<sections>
|
281
311
|
<example id="_">
|
@@ -285,15 +315,18 @@ RSpec.describe Asciidoctor::ISO do
|
|
285
315
|
</sections>
|
286
316
|
</iso-standard>
|
287
317
|
OUTPUT
|
318
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
319
|
+
.to be_equivalent_to xmlpp(output)
|
288
320
|
end
|
289
321
|
|
290
322
|
it "processes preambles" do
|
291
|
-
|
323
|
+
input = <<~INPUT
|
292
324
|
#{ASCIIDOC_BLANK_HDR}
|
293
325
|
This is a preamble
|
294
326
|
|
295
327
|
== Section 1
|
296
328
|
INPUT
|
329
|
+
output = <<~OUTPUT
|
297
330
|
#{BLANK_HDR}
|
298
331
|
<preface>
|
299
332
|
<foreword id="_" obligation="informative">
|
@@ -308,15 +341,18 @@ RSpec.describe Asciidoctor::ISO do
|
|
308
341
|
</sections>
|
309
342
|
</iso-standard>
|
310
343
|
OUTPUT
|
344
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
345
|
+
.to be_equivalent_to xmlpp(output)
|
311
346
|
end
|
312
347
|
|
313
348
|
it "processes images" do
|
314
|
-
|
349
|
+
input = <<~INPUT
|
315
350
|
#{ASCIIDOC_BLANK_HDR}
|
316
351
|
.Split-it-right sample divider
|
317
352
|
image::spec/examples/rice_images/rice_image1.png[]
|
318
353
|
|
319
354
|
INPUT
|
355
|
+
output = <<~OUTPUT
|
320
356
|
#{BLANK_HDR}
|
321
357
|
<sections>
|
322
358
|
<figure id="_">
|
@@ -326,15 +362,18 @@ RSpec.describe Asciidoctor::ISO do
|
|
326
362
|
</sections>
|
327
363
|
</iso-standard>
|
328
364
|
OUTPUT
|
365
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
366
|
+
.to be_equivalent_to xmlpp(output)
|
329
367
|
end
|
330
368
|
|
331
369
|
it "accepts width and height attributes on images" do
|
332
|
-
|
370
|
+
input = <<~INPUT
|
333
371
|
#{ASCIIDOC_BLANK_HDR}
|
334
372
|
[height=4,width=3]
|
335
373
|
image::spec/examples/rice_images/rice_image1.png[]
|
336
374
|
|
337
375
|
INPUT
|
376
|
+
output = <<~OUTPUT
|
338
377
|
#{BLANK_HDR}
|
339
378
|
<sections>
|
340
379
|
<figure id="_">
|
@@ -343,15 +382,18 @@ RSpec.describe Asciidoctor::ISO do
|
|
343
382
|
</sections>
|
344
383
|
</iso-standard>
|
345
384
|
OUTPUT
|
385
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
386
|
+
.to be_equivalent_to xmlpp(output)
|
346
387
|
end
|
347
388
|
|
348
389
|
it "accepts auto for width and height attributes on images" do
|
349
|
-
|
390
|
+
input = <<~INPUT
|
350
391
|
#{ASCIIDOC_BLANK_HDR}
|
351
392
|
[height=4,width=auto]
|
352
393
|
image::spec/examples/rice_images/rice_image1.png[]
|
353
394
|
|
354
395
|
INPUT
|
396
|
+
output = <<~OUTPUT
|
355
397
|
#{BLANK_HDR}
|
356
398
|
<sections>
|
357
399
|
<figure id="_">
|
@@ -360,30 +402,36 @@ RSpec.describe Asciidoctor::ISO do
|
|
360
402
|
</sections>
|
361
403
|
</iso-standard>
|
362
404
|
OUTPUT
|
405
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
406
|
+
.to be_equivalent_to xmlpp(output)
|
363
407
|
end
|
364
408
|
|
365
409
|
it "accepts alignment attribute on paragraphs" do
|
366
|
-
|
410
|
+
input = <<~INPUT
|
367
411
|
#{ASCIIDOC_BLANK_HDR}
|
368
412
|
[align=right]
|
369
413
|
This para is right-aligned.
|
370
414
|
INPUT
|
415
|
+
output = <<~OUTPUT
|
371
416
|
#{BLANK_HDR}
|
372
417
|
<sections>
|
373
418
|
<p align="right" id="_">This para is right-aligned.</p>
|
374
419
|
</sections>
|
375
420
|
</iso-standard>
|
376
421
|
OUTPUT
|
422
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
423
|
+
.to be_equivalent_to xmlpp(output)
|
377
424
|
end
|
378
425
|
|
379
426
|
it "processes blockquotes" do
|
380
|
-
|
427
|
+
input = <<~INPUT
|
381
428
|
#{ASCIIDOC_BLANK_HDR}
|
382
429
|
[quote, ISO, "ISO7301,section 1"]
|
383
430
|
____
|
384
431
|
Block quotation
|
385
432
|
____
|
386
433
|
INPUT
|
434
|
+
output = <<~OUTPUT
|
387
435
|
#{BLANK_HDR}
|
388
436
|
<sections>
|
389
437
|
<quote id="_">
|
@@ -400,10 +448,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
400
448
|
</sections>
|
401
449
|
</iso-standard>
|
402
450
|
OUTPUT
|
451
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
452
|
+
.to be_equivalent_to xmlpp(output)
|
403
453
|
end
|
404
454
|
|
405
455
|
it "processes source code" do
|
406
|
-
|
456
|
+
input = <<~INPUT
|
407
457
|
#{ASCIIDOC_BLANK_HDR}
|
408
458
|
[source,ruby]
|
409
459
|
--
|
@@ -413,6 +463,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
413
463
|
end
|
414
464
|
--
|
415
465
|
INPUT
|
466
|
+
output = <<~OUTPUT
|
416
467
|
#{BLANK_HDR}
|
417
468
|
<sections>
|
418
469
|
<sourcecode id="_" lang="ruby">
|
@@ -424,10 +475,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
424
475
|
</sections>
|
425
476
|
</iso-standard>
|
426
477
|
OUTPUT
|
478
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
479
|
+
.to be_equivalent_to xmlpp(output)
|
427
480
|
end
|
428
481
|
|
429
482
|
it "processes callouts" do
|
430
|
-
|
483
|
+
input = <<~INPUT
|
431
484
|
#{ASCIIDOC_BLANK_HDR}
|
432
485
|
[source,ruby]
|
433
486
|
--
|
@@ -439,6 +492,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
439
492
|
<1> This is one callout
|
440
493
|
<2> This is another callout
|
441
494
|
INPUT
|
495
|
+
output = <<~OUTPUT
|
442
496
|
#{BLANK_HDR}
|
443
497
|
<sections>
|
444
498
|
<sourcecode id="_" lang="ruby">
|
@@ -456,10 +510,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
456
510
|
</sections>
|
457
511
|
</iso-standard>
|
458
512
|
OUTPUT
|
513
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
514
|
+
.to be_equivalent_to xmlpp(output)
|
459
515
|
end
|
460
516
|
|
461
517
|
it "processes unmodified term sources" do
|
462
|
-
|
518
|
+
input = <<~INPUT
|
463
519
|
#{ASCIIDOC_BLANK_HDR}
|
464
520
|
== Terms and Definitions
|
465
521
|
|
@@ -468,6 +524,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
468
524
|
[.source]
|
469
525
|
<<ISO2191,section=1>>
|
470
526
|
INPUT
|
527
|
+
output = <<~OUTPUT
|
471
528
|
#{BLANK_HDR}
|
472
529
|
<sections>
|
473
530
|
<terms id="_" obligation="normative">
|
@@ -488,10 +545,12 @@ RSpec.describe Asciidoctor::ISO do
|
|
488
545
|
</sections>
|
489
546
|
</iso-standard>
|
490
547
|
OUTPUT
|
548
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
549
|
+
.to be_equivalent_to xmlpp(output)
|
491
550
|
end
|
492
551
|
|
493
552
|
it "processes modified term sources" do
|
494
|
-
|
553
|
+
input = <<~INPUT
|
495
554
|
#{ASCIIDOC_BLANK_HDR}
|
496
555
|
== Terms and Definitions
|
497
556
|
|
@@ -500,6 +559,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
500
559
|
[.source]
|
501
560
|
<<ISO2191,section=1>>, with adjustments
|
502
561
|
INPUT
|
562
|
+
output = <<~OUTPUT
|
503
563
|
#{BLANK_HDR}
|
504
564
|
<sections>
|
505
565
|
<terms id="_" obligation="normative">
|
@@ -523,5 +583,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
523
583
|
</sections>
|
524
584
|
</iso-standard>
|
525
585
|
OUTPUT
|
586
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
587
|
+
.to be_equivalent_to xmlpp(output)
|
526
588
|
end
|
527
589
|
end
|