metanorma-standoc 1.10.7 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +19 -23
  3. data/Rakefile +1 -1
  4. data/lib/asciidoctor/standoc/base.rb +7 -4
  5. data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
  6. data/lib/asciidoctor/standoc/blocks.rb +23 -23
  7. data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
  8. data/lib/asciidoctor/standoc/cleanup.rb +20 -11
  9. data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +45 -7
  11. data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
  12. data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
  13. data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
  14. data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
  15. data/lib/asciidoctor/standoc/cleanup_terms.rb +48 -77
  16. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +162 -0
  17. data/lib/asciidoctor/standoc/cleanup_text.rb +23 -0
  18. data/lib/asciidoctor/standoc/converter.rb +2 -0
  19. data/lib/asciidoctor/standoc/inline.rb +7 -5
  20. data/lib/asciidoctor/standoc/isodoc.rng +420 -76
  21. data/lib/asciidoctor/standoc/lists.rb +14 -16
  22. data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
  23. data/lib/asciidoctor/standoc/macros_terms.rb +55 -8
  24. data/lib/asciidoctor/standoc/ref.rb +1 -1
  25. data/lib/asciidoctor/standoc/ref_sect.rb +26 -18
  26. data/lib/asciidoctor/standoc/reqt.rng +23 -2
  27. data/lib/asciidoctor/standoc/section.rb +13 -12
  28. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
  29. data/lib/asciidoctor/standoc/terms.rb +12 -2
  30. data/lib/asciidoctor/standoc/utils.rb +36 -23
  31. data/lib/asciidoctor/standoc/validate.rb +45 -27
  32. data/lib/asciidoctor/standoc/validate_section.rb +5 -2
  33. data/lib/metanorma/standoc/version.rb +1 -1
  34. data/metanorma-standoc.gemspec +1 -1
  35. data/spec/asciidoctor/base_spec.rb +4 -3
  36. data/spec/asciidoctor/blocks_spec.rb +230 -49
  37. data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
  38. data/spec/asciidoctor/cleanup_spec.rb +105 -286
  39. data/spec/asciidoctor/cleanup_terms_spec.rb +1020 -0
  40. data/spec/asciidoctor/inline_spec.rb +2 -2
  41. data/spec/asciidoctor/lists_spec.rb +6 -6
  42. data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
  43. data/spec/asciidoctor/macros_spec.rb +190 -113
  44. data/spec/asciidoctor/refs_dl_spec.rb +4 -4
  45. data/spec/asciidoctor/refs_spec.rb +268 -108
  46. data/spec/asciidoctor/section_spec.rb +18 -18
  47. data/spec/asciidoctor/validate_spec.rb +87 -2
  48. data/spec/spec_helper.rb +8 -8
  49. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
  50. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  51. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  52. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  53. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +31 -31
  54. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  55. data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
  56. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  57. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
  58. metadata +8 -5
@@ -0,0 +1,1020 @@
1
+ require "spec_helper"
2
+ require "relaton_iec"
3
+ require "fileutils"
4
+
5
+ RSpec.describe Asciidoctor::Standoc do
6
+ it "processes term and designation metadata and term sources" do
7
+ input = <<~INPUT
8
+ #{ASCIIDOC_BLANK_HDR}
9
+ == Terms and Definitions
10
+
11
+ === First Designation
12
+
13
+ [%metadata]
14
+ language:: fr
15
+ script:: Latn
16
+ type:: prefix
17
+ isInternational:: true
18
+ abbreviationType:: acronym
19
+ pronunciation:: fəɹst
20
+ domain:: Hydraulics
21
+ subject:: pipes
22
+ usageinfo:: This is usage.
23
+
24
+ [.source]
25
+ <<ISO2191,section=1>>
26
+
27
+ alt:[Third Designation]
28
+
29
+ [%metadata]
30
+ language:: he
31
+ script:: Hebr
32
+ type:: suffix
33
+ domain:: Hydraulics1
34
+ subject: pipes1
35
+ usageinfo:: This is usage 1.
36
+ absent:: true
37
+
38
+ deprecated:[Fourth Designation]
39
+
40
+ [%metadata]
41
+ language:: jp
42
+ script:: Japn
43
+ type:: full
44
+ grammar::
45
+ gender::: masculine, feminine
46
+ isPreposition::: false
47
+ isNoun::: true
48
+ grammarValue::: irregular declension
49
+ geographicArea:: AUS
50
+
51
+ related:see[<<second>>,Fifth Designation]
52
+
53
+ [%metadata]
54
+ type:: abbreviation
55
+ grammar::
56
+ gender::: neuter
57
+ isVerb::: true
58
+ geographicArea:: GRC
59
+
60
+ [.source]
61
+ <<ISO2191,section=2>>
62
+
63
+ Definition
64
+
65
+ [.source]
66
+ <<ISO2191,section=3>>
67
+
68
+ [[second]]
69
+ === Second Term
70
+
71
+ [%metadata]
72
+ usageinfo::
73
+ +
74
+ --
75
+ Usage Info 1.
76
+
77
+ Usage Info 2.
78
+ --
79
+
80
+ INPUT
81
+ output = <<~OUTPUT
82
+ #{BLANK_HDR}
83
+ <sections>
84
+ <terms id='_' obligation='normative'>
85
+ <title>Terms and definitions</title>
86
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
87
+ <term id='term-first-designation'>
88
+ <preferred language='fr' script='Latn' type='prefix' isInternational="true">
89
+ <expression>
90
+ <name>First Designation</name>
91
+ <abbreviationType>acronym</abbreviationType>
92
+ <pronunciation>f&#601;&#633;st</pronunciation>
93
+ </expression>
94
+ <termsource status='identical' type='authoritative'>
95
+ <origin bibitemid='ISO2191' type='inline' citeas=''>
96
+ <localityStack>
97
+ <locality type='section'>
98
+ <referenceFrom>1</referenceFrom>
99
+ </locality>
100
+ </localityStack>
101
+ </origin>
102
+ </termsource>
103
+ </preferred>
104
+ <admitted language='he' script='Hebr' type='suffix' absent="true">
105
+ <expression>
106
+ <name>Third Designation</name>
107
+ </expression>
108
+ </admitted>
109
+ <deprecates language='jp' script='Japn' type='full' geographicArea="AUS">
110
+ <expression>
111
+ <name>Fourth Designation</name>
112
+ <grammar>
113
+ <gender>masculine</gender>
114
+ <gender>feminine</gender>
115
+ <isPreposition>false</isPreposition>
116
+ <isNoun>true</isNoun>
117
+ <grammarValue>irregular declension</grammarValue>
118
+ </grammar>
119
+ </expression>
120
+ </deprecates>
121
+ <related type='abbreviation'>
122
+ <preferred geographicArea="GRC">
123
+ <expression>
124
+ <name>Fifth Designation</name>
125
+ <grammar>
126
+ <gender>neuter</gender>
127
+ </grammar>
128
+ </expression>
129
+ <termsource status='identical' type='authoritative'>
130
+ <origin bibitemid='ISO2191' type='inline' citeas=''>
131
+ <localityStack>
132
+ <locality type='section'>
133
+ <referenceFrom>2</referenceFrom>
134
+ </locality>
135
+ </localityStack>
136
+ </origin>
137
+ </termsource>
138
+ </preferred>
139
+ <xref target='second'/>
140
+ </related>
141
+ <domain>Hydraulics</domain>
142
+ <subject>pipes</subject>
143
+ <usageinfo>This is usage.</usageinfo>
144
+ <definition><verbaldefinition>
145
+ <p id='_'>Definition</p>
146
+ </verbaldefinition></definition>
147
+ <termsource status='identical' type='authoritative'>
148
+ <origin bibitemid='ISO2191' type='inline' citeas=''>
149
+ <localityStack>
150
+ <locality type='section'>
151
+ <referenceFrom>3</referenceFrom>
152
+ </locality>
153
+ </localityStack>
154
+ </origin>
155
+ </termsource>
156
+ </term>
157
+ <term id='second'>
158
+ <preferred>
159
+ <expression>
160
+ <name>Second Term</name>
161
+ </expression>
162
+ </preferred>
163
+ <usageinfo>
164
+ <p id='_'>Usage Info 1.</p>
165
+ <p id='_'>Usage Info 2.</p>
166
+ </usageinfo>
167
+ </term>
168
+ </terms>
169
+ </sections>
170
+ </standard-document>
171
+ OUTPUT
172
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
173
+ .to be_equivalent_to xmlpp(output)
174
+ end
175
+
176
+ it "permits multiple preferred terms, and treats them as synonyms in concepts" do
177
+ input = <<~INPUT
178
+ #{ASCIIDOC_BLANK_HDR}
179
+ == Terms and Definitions
180
+
181
+ === First Designation
182
+
183
+ preferred:[Second Designation]
184
+
185
+ alt:[Third Designation]
186
+
187
+ alt:[Fourth Designation]
188
+
189
+ deprecated:[Fourth Designation]
190
+
191
+ deprecated:[Fifth Designation]
192
+
193
+ related:see[Sixth Designation]
194
+
195
+ related:contrast[Seventh Designation]
196
+
197
+ Definition
198
+
199
+ == Clause
200
+
201
+ {{First Designation}}
202
+
203
+ {{Second Designation}}
204
+ INPUT
205
+ output = <<~OUTPUT
206
+ #{BLANK_HDR}
207
+ <sections>
208
+ <terms id='_' obligation='normative'>
209
+ <title>Terms and definitions</title>
210
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
211
+ <term id='term-first-designation'>
212
+ <preferred>
213
+ <expression>
214
+ <name>First Designation</name>
215
+ </expression>
216
+ </preferred>
217
+ <preferred>
218
+ <expression>
219
+ <name>Second Designation</name>
220
+ </expression>
221
+ </preferred>
222
+ <admitted>
223
+ <expression>
224
+ <name>Third Designation</name>
225
+ </expression>
226
+ </admitted>
227
+ <admitted>
228
+ <expression>
229
+ <name>Fourth Designation</name>
230
+ </expression>
231
+ </admitted>
232
+ <deprecates>
233
+ <expression>
234
+ <name>Fourth Designation</name>
235
+ </expression>
236
+ </deprecates>
237
+ <deprecates>
238
+ <expression>
239
+ <name>Fifth Designation</name>
240
+ </expression>
241
+ </deprecates>
242
+ <related type='see'>
243
+ <strong>
244
+ term
245
+ <tt>Sixth Designation</tt>
246
+ not resolved via ID
247
+ <tt>sixth-designation</tt>
248
+ </strong>
249
+ </related>
250
+ <related type='contrast'>
251
+ <strong>
252
+ term
253
+ <tt>Seventh Designation</tt>
254
+ not resolved via ID
255
+ <tt>seventh-designation</tt>
256
+ </strong>
257
+ </related>
258
+ <definition><verbaldefinition>
259
+ <p id='_'>Definition</p>
260
+ </verbaldefinition></definition>
261
+ </term>
262
+ </terms>
263
+ <clause id='_' inline-header='false' obligation='normative'>
264
+ <title>Clause</title>
265
+ <p id='_'>
266
+ <concept>
267
+ <refterm>First Designation</refterm>
268
+ <renderterm>First Designation</renderterm>
269
+ <xref target='term-first-designation'/>
270
+ </concept>
271
+ </p>
272
+ <p id='_'>
273
+ <concept>
274
+ <refterm>Second Designation</refterm>
275
+ <renderterm>Second Designation</renderterm>
276
+ <xref target='term-first-designation'/>
277
+ </concept>
278
+ </p>
279
+ </clause>
280
+ </sections>
281
+ </standard-document>
282
+ OUTPUT
283
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
284
+ .to be_equivalent_to xmlpp(output)
285
+ end
286
+
287
+ it "processes letter-symbol designations" do
288
+ input = <<~INPUT
289
+ #{ASCIIDOC_BLANK_HDR}
290
+ == Terms and Definitions
291
+
292
+ === First Designation
293
+
294
+ [%metadata]
295
+ letter-symbol:: true
296
+
297
+ preferred:[Second Designation]
298
+
299
+ [%metadata]
300
+ letter-symbol:: false
301
+
302
+ alt:[Third Designation]
303
+
304
+ [%metadata]
305
+ letter-symbol:: true
306
+
307
+ deprecated:[stem:[t_90]]
308
+
309
+ related:see[<<second>>,Fifth Designation]
310
+
311
+ [%metadata]
312
+ letter-symbol:: true
313
+
314
+ Definition
315
+ INPUT
316
+ output = <<~OUTPUT
317
+ #{BLANK_HDR}
318
+ <sections>
319
+ <terms id='_' obligation='normative'>
320
+ <title>Terms and definitions</title>
321
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
322
+ <term id='term-first-designation'>
323
+ <preferred>
324
+ <letter-symbol>
325
+ <name>First Designation</name>
326
+ </letter-symbol>
327
+ </preferred>
328
+ <preferred>
329
+ <expression>
330
+ <name>Second Designation</name>
331
+ </expression>
332
+ </preferred>
333
+ <admitted>
334
+ <letter-symbol>
335
+ <name>Third Designation</name>
336
+ </letter-symbol>
337
+ </admitted>
338
+ <deprecates>
339
+ <letter-symbol>
340
+ <name>
341
+ <stem type='MathML'>
342
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
343
+ <msub>
344
+ <mrow>
345
+ <mi>t</mi>
346
+ </mrow>
347
+ <mrow>
348
+ <mn>90</mn>
349
+ </mrow>
350
+ </msub>
351
+ </math>
352
+ </stem>
353
+ </name>
354
+ </letter-symbol>
355
+ </deprecates>
356
+ <related type='see'>
357
+ <preferred>
358
+ <letter-symbol>
359
+ <name>Fifth Designation</name>
360
+ </letter-symbol>
361
+ </preferred>
362
+ <xref target='second'/>
363
+ </related>
364
+ <definition><verbaldefinition>
365
+ <p id='_'>Definition</p>
366
+ </verbaldefinition></definition>
367
+ </term>
368
+ </terms>
369
+ </sections>
370
+ </standard-document>
371
+ OUTPUT
372
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
373
+ .to be_equivalent_to xmlpp(output)
374
+ end
375
+
376
+ it "processes empty designations" do
377
+ input = <<~INPUT
378
+ #{ASCIIDOC_BLANK_HDR}
379
+ == Terms and Definitions
380
+
381
+ [[second]]
382
+ === {blank}
383
+
384
+ [%metadata]
385
+ isInternational:: true
386
+
387
+ preferred:[]
388
+
389
+ alt:[]
390
+
391
+ deprecated:[]
392
+
393
+ related:see[<<second>>,]
394
+
395
+ Definition
396
+ INPUT
397
+ output = <<~OUTPUT
398
+ #{BLANK_HDR}
399
+ <sections>
400
+ <terms id='_' obligation='normative'>
401
+ <title>Terms and definitions</title>
402
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
403
+ <term id='second'>
404
+ <preferred isInternational='true'>
405
+ <expression>
406
+ <name/>
407
+ </expression>
408
+ </preferred>
409
+ <preferred>
410
+ <expression>
411
+ <name/>
412
+ </expression>
413
+ </preferred>
414
+ <admitted>
415
+ <expression>
416
+ <name/>
417
+ </expression>
418
+ </admitted>
419
+ <deprecates>
420
+ <expression>
421
+ <name> </name>
422
+ </expression>
423
+ </deprecates>
424
+ <related type='see'>
425
+ <xref target='second'/>
426
+ </related>
427
+ <definition><verbaldefinition>
428
+ <p id='_'>Definition</p>
429
+ </verbaldefinition></definition>
430
+ </term>
431
+ </terms>
432
+ </sections>
433
+ </standard-document>
434
+ OUTPUT
435
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
436
+ .to be_equivalent_to xmlpp(output)
437
+ end
438
+
439
+ it "processes graphical-symbol designations" do
440
+ input = <<~INPUT
441
+ #{ASCIIDOC_BLANK_HDR}
442
+ == Terms and Definitions
443
+
444
+ [[second]]
445
+ === {blank}
446
+
447
+ .Caption
448
+ ....
449
+ <LITERAL>
450
+ FIGURATIVE
451
+ ....
452
+
453
+ [%metadata]
454
+ isInternational:: true
455
+
456
+ preferred:[]
457
+
458
+ .Caption
459
+ ....
460
+ <LITERAL>
461
+ FIGURATIVE
462
+ ....
463
+
464
+ alt:[]
465
+
466
+ .Caption
467
+ ....
468
+ <LITERAL>
469
+ FIGURATIVE
470
+ ....
471
+
472
+ deprecated:[]
473
+
474
+ .Caption
475
+ ....
476
+ <LITERAL>
477
+ FIGURATIVE
478
+ ....
479
+
480
+ related:see[<<second>>,]
481
+
482
+ .Caption
483
+ ....
484
+ <LITERAL>
485
+ FIGURATIVE
486
+ ....
487
+
488
+ Definition
489
+ INPUT
490
+ output = <<~OUTPUT
491
+ #{BLANK_HDR}
492
+ <sections>
493
+ <terms id='_' obligation='normative'>
494
+ <title>Terms and definitions</title>
495
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
496
+ <term id='second'>
497
+ <preferred isInternational='true'>
498
+ <graphical-symbol>
499
+ <figure id='_'>
500
+ <pre id='_'>&lt;LITERAL&gt; FIGURATIVE</pre>
501
+ </figure>
502
+ </graphical-symbol>
503
+ </preferred>
504
+ <preferred>
505
+ <graphical-symbol>
506
+ <figure id='_'>
507
+ <pre id='_'>&lt;LITERAL&gt; FIGURATIVE</pre>
508
+ </figure>
509
+ </graphical-symbol>
510
+ </preferred>
511
+ <admitted>
512
+ <graphical-symbol>
513
+ <figure id='_'>
514
+ <pre id='_'>&lt;LITERAL&gt; FIGURATIVE</pre>
515
+ </figure>
516
+ </graphical-symbol>
517
+ </admitted>
518
+ <deprecates>
519
+ <graphical-symbol>
520
+ <figure id='_'>
521
+ <pre id='_'>&lt;LITERAL&gt; FIGURATIVE</pre>
522
+ </figure>
523
+ </graphical-symbol>
524
+ </deprecates>
525
+ <related type='see'>
526
+ <xref target='second'/>
527
+ </related>
528
+ <definition>
529
+ <verbaldefinition><p id='_'>Definition</p></verbaldefinition>
530
+ <nonverbalrepresentation>
531
+ <figure id='_'>
532
+ <name>Caption</name>
533
+ <pre id='_'>&lt;LITERAL&gt; FIGURATIVE</pre>
534
+ </figure>
535
+ </nonverbalrepresentation>
536
+ </definition>
537
+ </term>
538
+ </terms>
539
+ </sections>
540
+ </standard-document>
541
+ OUTPUT
542
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
543
+ .to be_equivalent_to xmlpp(output)
544
+ end
545
+
546
+ it "sorts designations" do
547
+ input = <<~INPUT
548
+ #{ASCIIDOC_BLANK_HDR}
549
+ == Terms and Definitions
550
+
551
+ === First Designation
552
+
553
+ [%metadata]
554
+ language:: fr
555
+ script:: Latn
556
+ type:: prefix
557
+ isInternational:: true
558
+ abbreviationType:: acronym
559
+ pronunciation:: fəɹst
560
+ domain:: Hydraulics
561
+ subject:: pipes
562
+ usageinfo:: This is usage.
563
+
564
+ related:see[Fifth Designation]
565
+
566
+ [%metadata]
567
+ grammar::
568
+ gender::: neuter
569
+ isVerb::: true
570
+
571
+ deprecated:[Fourth Designation]
572
+
573
+ [%metadata]
574
+ language:: jp
575
+ script:: Japn
576
+ type:: full
577
+ grammar::
578
+ gender::: masculine, feminine
579
+ isPreposition::: false
580
+ isNoun::: true
581
+ grammarValue::: irregular declension
582
+
583
+ alt:[Third Designation]
584
+
585
+ [%metadata]
586
+ language:: he
587
+ script:: Hebr
588
+ type:: suffix
589
+ domain:: Hydraulics1
590
+ subject: pipes1
591
+ usageinfo:: This is usage 1.
592
+
593
+ preferred:[Second Designation]
594
+
595
+ [%metadata]
596
+ type:: abbreviation
597
+
598
+ Definition
599
+
600
+ INPUT
601
+ output = <<~OUTPUT
602
+ #{BLANK_HDR}
603
+ <sections>
604
+ <terms id='_' obligation='normative'>
605
+ <title>Terms and definitions</title>
606
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
607
+ <term id='term-first-designation'>
608
+ <preferred language='fr' script='Latn' type='prefix' isInternational="true">
609
+ <expression>
610
+ <name>First Designation</name>
611
+ <abbreviationType>acronym</abbreviationType>
612
+ <pronunciation>f&#601;&#633;st</pronunciation>
613
+ </expression>
614
+ </preferred>
615
+ <preferred type='abbreviation'>
616
+ <expression>
617
+ <name>Second Designation</name>
618
+ </expression>
619
+ </preferred>
620
+ <admitted language='he' script='Hebr' type='suffix'>
621
+ <expression>
622
+ <name>Third Designation</name>
623
+ </expression>
624
+ </admitted>
625
+ <deprecates language='jp' script='Japn' type='full'>
626
+ <expression>
627
+ <name>Fourth Designation</name>
628
+ <grammar>
629
+ <gender>masculine</gender>
630
+ <gender>feminine</gender>
631
+ <isPreposition>false</isPreposition>
632
+ <isNoun>true</isNoun>
633
+ <grammarValue>irregular declension</grammarValue>
634
+ </grammar>
635
+ </expression>
636
+ </deprecates>
637
+ <related type='see'>
638
+ <strong>
639
+ term
640
+ <tt>Fifth Designation</tt>
641
+ not resolved via ID
642
+ <tt>fifth-designation</tt>
643
+ </strong>
644
+ </related>
645
+ <domain>Hydraulics</domain>
646
+ <subject>pipes</subject>
647
+ <usageinfo>This is usage.</usageinfo>
648
+ <definition><verbaldefinition>
649
+ <p id='_'>Definition</p>
650
+ </verbaldefinition></definition>
651
+ </term>
652
+ </terms>
653
+ </sections>
654
+ </standard-document>
655
+ OUTPUT
656
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
657
+ .to be_equivalent_to xmlpp(output)
658
+ end
659
+
660
+ it "processes stem-only terms as admitted" do
661
+ input = <<~INPUT
662
+ #{ASCIIDOC_BLANK_HDR}
663
+ == Terms and Definitions
664
+
665
+ === stem:[t_90]
666
+
667
+ stem:[t_91]
668
+
669
+ Time
670
+ INPUT
671
+ output = <<~OUTPUT
672
+ #{BLANK_HDR}
673
+ <sections>
674
+ <terms id="_" obligation="normative">
675
+ <title>Terms and definitions</title>
676
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
677
+ <term id="term-t90"><preferred><letter-symbol><name><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
678
+ <mrow>
679
+ <mi>t</mi>
680
+ </mrow>
681
+ <mrow>
682
+ <mn>90</mn>
683
+ </mrow>
684
+ </msub></math></stem></name></letter-symbol></preferred>
685
+ <admitted><letter-symbol><name><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
686
+ <mrow>
687
+ <mi>t</mi>
688
+ </mrow>
689
+ <mrow>
690
+ <mn>91</mn>
691
+ </mrow>
692
+ </msub></math></stem></name></letter-symbol></admitted>
693
+ <definition><verbaldefinition><p id="_">Time</p></verbaldefinition></definition></term>
694
+ </terms>
695
+ </sections>
696
+ </standard-document>
697
+ OUTPUT
698
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
699
+ .to be_equivalent_to xmlpp(output)
700
+ end
701
+
702
+ it "moves term domains out of the term definition paragraph" do
703
+ input = <<~INPUT
704
+ #{ASCIIDOC_BLANK_HDR}
705
+ == Terms and Definitions
706
+
707
+ === Tempus
708
+
709
+ domain:[relativity] Time
710
+
711
+ === Tempus1
712
+
713
+ Time2
714
+
715
+ domain:[relativity2]
716
+ INPUT
717
+ output = <<~OUTPUT
718
+ #{BLANK_HDR}
719
+ <sections>
720
+ <terms id="_" obligation="normative">
721
+ <title>Terms and definitions</title>
722
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
723
+ <term id="term-tempus">
724
+ <preferred><expression><name>Tempus</name></expression></preferred>
725
+ <domain>relativity</domain><definition><verbaldefinition><p id="_"> Time</p></verbaldefinition></definition>
726
+ </term>
727
+ <term id='term-tempus1'>
728
+ <preferred><expression><name>Tempus1</name></expression></preferred>
729
+ <domain>relativity2</domain>
730
+ <definition><verbaldefinition>
731
+ <p id='_'>Time2</p>
732
+ <p id='_'> </p>
733
+ </verbaldefinition></definition>
734
+ </term>
735
+ </terms>
736
+ </sections>
737
+ </standard-document>
738
+ OUTPUT
739
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
740
+ .to be_equivalent_to xmlpp(output)
741
+ end
742
+
743
+ it "permits multiple blocks in term definition paragraph" do
744
+ input = <<~INPUT
745
+ = Document title
746
+ Author
747
+ :docfile: test.adoc
748
+ :nodoc:
749
+ :novalid:
750
+ :stem:
751
+
752
+ == Terms and Definitions
753
+
754
+ === stem:[t_90]
755
+
756
+ [stem]
757
+ ++++
758
+ t_A
759
+ ++++
760
+
761
+ This paragraph is extraneous
762
+
763
+ * This is a list
764
+
765
+ []
766
+ . This too is a list
767
+
768
+ []
769
+ This is:: another list
770
+
771
+
772
+ This is a concluding paragraph
773
+ INPUT
774
+ output = <<~OUTPUT
775
+ #{BLANK_HDR}
776
+ <sections>
777
+ <terms id="_" obligation="normative">
778
+ <title>Terms and definitions</title>
779
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
780
+ <term id="term-t90"><preferred><letter-symbol><name><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
781
+ <mrow>
782
+ <mi>t</mi>
783
+ </mrow>
784
+ <mrow>
785
+ <mn>90</mn>
786
+ </mrow>
787
+ </msub></math></stem></name></letter-symbol></preferred>
788
+ <definition>
789
+ <verbaldefinition>
790
+ <p id="_">This paragraph is extraneous</p>
791
+ <ul id='_'>
792
+ <li>
793
+ <p id='_'>This is a list</p>
794
+ </li>
795
+ </ul>
796
+ <ol id='_' type='arabic'>
797
+ <li>
798
+ <p id='_'>This too is a list</p>
799
+ </li>
800
+ </ol>
801
+ <dl id='_'>
802
+ <dt>This is</dt>
803
+ <dd>
804
+ <p id='_'>another list</p>
805
+ </dd>
806
+ </dl>
807
+ <p id='_'>This is a concluding paragraph</p>
808
+ </verbaldefinition>
809
+ <nonverbalrepresentation><formula id="_">
810
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
811
+ <mrow>
812
+ <mi>t</mi>
813
+ </mrow>
814
+ <mrow>
815
+ <mi>A</mi>
816
+ </mrow>
817
+ </msub></math></stem>
818
+ </formula></nonverbalrepresentation>
819
+ </definition>
820
+ </term>
821
+ </terms>
822
+ </sections>
823
+ </standard-document>
824
+ OUTPUT
825
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
826
+ .to be_equivalent_to xmlpp(output)
827
+ end
828
+
829
+ it "rearranges term note, term example, term source" do
830
+ input = <<~INPUT
831
+ #{ASCIIDOC_BLANK_HDR}
832
+
833
+ == Terms and definitions
834
+
835
+ === Term
836
+
837
+ Definition
838
+
839
+ [.source]
840
+ <<ISO2191,section=1>>
841
+
842
+ NOTE: Note
843
+
844
+ [example]
845
+ Example 1
846
+
847
+ NOTE: Note 2
848
+
849
+ [example]
850
+ Example 2
851
+ INPUT
852
+ output = <<~OUTPUT
853
+ #{BLANK_HDR}
854
+ <sections>
855
+ <terms id="_" obligation="normative">
856
+ <title>Terms and definitions</title>
857
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
858
+ <term id="term-term"><preferred><expression><name>Term</name></expression></preferred>
859
+ <definition><verbaldefinition><p id='_'>Definition</p></verbaldefinition></definition>
860
+ <termnote id="_">
861
+ <p id="_">Note</p>
862
+ </termnote><termnote id="_">
863
+ <p id="_">Note 2</p>
864
+ </termnote><termexample id="_">
865
+ <p id="_">Example 1</p>
866
+ </termexample><termexample id="_">
867
+ <p id="_">Example 2</p>
868
+ </termexample><termsource status="identical" type="authoritative">
869
+ <origin bibitemid="ISO2191" type="inline" citeas="">
870
+ <localityStack>
871
+ <locality type="section"><referenceFrom>1</referenceFrom></locality>
872
+ </localityStack>
873
+ </origin>
874
+ </termsource></term>
875
+ </terms>
876
+ </sections>
877
+ </standard-document>
878
+ OUTPUT
879
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
880
+ .to be_equivalent_to xmlpp(output)
881
+ end
882
+
883
+ it "supports non-verbal definitions" do
884
+ input = <<~INPUT
885
+ #{ASCIIDOC_BLANK_HDR}
886
+
887
+ == Terms and definitions
888
+
889
+ === Term
890
+
891
+ [.definition]
892
+ --
893
+
894
+ Definition
895
+
896
+ [.source]
897
+ <<ISO2191,section=1>>
898
+
899
+ |===
900
+ | A | B
901
+
902
+ | C | D
903
+ |===
904
+ --
905
+
906
+ [.source]
907
+ <<ISO2191,section=2>>
908
+
909
+ === Term 2
910
+
911
+ [.definition]
912
+ --
913
+
914
+ ....
915
+ Literal
916
+ ....
917
+
918
+ [stem]
919
+ ++++
920
+ x = y
921
+ ++++
922
+
923
+ [.source]
924
+ <<ISO2191,section=3>>
925
+ --
926
+
927
+ INPUT
928
+ output = <<~OUTPUT
929
+ #{BLANK_HDR}
930
+ <sections>
931
+ <terms id='_' obligation='normative'>
932
+ <title>Terms and definitions</title>
933
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
934
+ <term id='term-term'>
935
+ <preferred>
936
+ <expression>
937
+ <name>Term</name>
938
+ </expression>
939
+ </preferred>
940
+ <definition>
941
+ <verbaldefinition>
942
+ <p id='_'>Definition</p>
943
+ <termsource status='identical' type='authoritative'>
944
+ <origin bibitemid='ISO2191' type='inline' citeas=''>
945
+ <localityStack>
946
+ <locality type='section'>
947
+ <referenceFrom>1</referenceFrom>
948
+ </locality>
949
+ </localityStack>
950
+ </origin>
951
+ </termsource>
952
+ </verbaldefinition>
953
+ <nonverbalrepresentation>
954
+ <table id='_'>
955
+ <thead>
956
+ <tr>
957
+ <th valign='top' align='left'>A</th>
958
+ <th valign='top' align='left'>B</th>
959
+ </tr>
960
+ </thead>
961
+ <tbody>
962
+ <tr>
963
+ <td valign='top' align='left'>C</td>
964
+ <td valign='top' align='left'>D</td>
965
+ </tr>
966
+ </tbody>
967
+ </table>
968
+ </nonverbalrepresentation>
969
+ </definition>
970
+ <termsource status='identical' type='authoritative'>
971
+ <origin bibitemid='ISO2191' type='inline' citeas=''>
972
+ <localityStack>
973
+ <locality type='section'>
974
+ <referenceFrom>2</referenceFrom>
975
+ </locality>
976
+ </localityStack>
977
+ </origin>
978
+ </termsource>
979
+ </term>
980
+ <term id='term-term-2'>
981
+ <preferred>
982
+ <expression>
983
+ <name>Term 2</name>
984
+ </expression>
985
+ </preferred>
986
+ <definition>
987
+ <nonverbalrepresentation>
988
+ <figure id='_'>
989
+ <pre id='_'>Literal</pre>
990
+ </figure>
991
+ <formula id='_'>
992
+ <stem type='MathML'>
993
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
994
+ <mi>x</mi>
995
+ <mo>=</mo>
996
+ <mi>y</mi>
997
+ </math>
998
+ </stem>
999
+ </formula>
1000
+ <termsource status='identical' type='authoritative'>
1001
+ <origin bibitemid='ISO2191' type='inline' citeas=''>
1002
+ <localityStack>
1003
+ <locality type='section'>
1004
+ <referenceFrom>3</referenceFrom>
1005
+ </locality>
1006
+ </localityStack>
1007
+ </origin>
1008
+ </termsource>
1009
+ </nonverbalrepresentation>
1010
+ </definition>
1011
+ </term>
1012
+ </terms>
1013
+ </sections>
1014
+ </standard-document>
1015
+ OUTPUT
1016
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
1017
+ .to be_equivalent_to xmlpp(output)
1018
+ end
1019
+
1020
+ end