metanorma-iso 1.8.6 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.8.6".freeze
3
+ VERSION = "1.9.0".freeze
4
4
  end
5
5
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency "isodoc", "~> 1.7.0"
33
33
  spec.add_dependency "metanorma-standoc", "~> 1.10.0"
34
- spec.add_dependency "mn2sts", "~> 1.8.0"
34
+ spec.add_dependency "mnconvert", "~> 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 sections" do
5
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
5
+ input = <<~INPUT
6
6
  #{ASCIIDOC_BLANK_HDR}
7
7
  == Foreword
8
8
 
@@ -56,6 +56,7 @@ RSpec.describe Asciidoctor::ISO do
56
56
 
57
57
  === Bibliography Subsection
58
58
  INPUT
59
+ output = <<~OUTPUT
59
60
  #{BLANK_HDR}
60
61
  <preface>
61
62
  <foreword id="_" obligation="informative">
@@ -151,10 +152,12 @@ RSpec.describe Asciidoctor::ISO do
151
152
  </bibliography>
152
153
  </iso-standard>
153
154
  OUTPUT
155
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
156
+ .to be_equivalent_to xmlpp(output)
154
157
  end
155
158
 
156
159
  it "processes section obligations" do
157
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
160
+ input = <<~INPUT
158
161
  #{ASCIIDOC_BLANK_HDR}
159
162
  [obligation=informative]
160
163
  == Clause 1
@@ -167,6 +170,7 @@ RSpec.describe Asciidoctor::ISO do
167
170
  [appendix,obligation=informative]
168
171
  == Annex
169
172
  INPUT
173
+ output = <<~OUTPUT
170
174
  #{BLANK_HDR}
171
175
  <sections>
172
176
  <clause id="_" inline-header="false" obligation="informative">
@@ -184,10 +188,12 @@ RSpec.describe Asciidoctor::ISO do
184
188
  </annex>
185
189
  </iso-standard>
186
190
  OUTPUT
191
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
192
+ .to be_equivalent_to xmlpp(output)
187
193
  end
188
194
 
189
195
  it "processes inline headers" do
190
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
196
+ input = <<~INPUT
191
197
  #{ASCIIDOC_BLANK_HDR}
192
198
  == Clause 1
193
199
 
@@ -200,6 +206,7 @@ RSpec.describe Asciidoctor::ISO do
200
206
  [%inline-header]
201
207
  === Clause Aa
202
208
  INPUT
209
+ output = <<~OUTPUT
203
210
  #{BLANK_HDR}
204
211
  <sections>
205
212
  <clause id="_" inline-header="false" obligation="normative">
@@ -217,16 +224,19 @@ RSpec.describe Asciidoctor::ISO do
217
224
  </annex>
218
225
  </iso-standard>
219
226
  OUTPUT
227
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
228
+ .to be_equivalent_to xmlpp(output)
220
229
  end
221
230
 
222
231
  it "processes blank headers" do
223
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
232
+ input = <<~INPUT
224
233
  #{ASCIIDOC_BLANK_HDR}
225
234
  == Clause 1
226
235
 
227
236
  === {blank}
228
237
 
229
238
  INPUT
239
+ output = <<~OUTPUT
230
240
  #{BLANK_HDR}
231
241
  <sections>
232
242
  <clause id="_" inline-header="false" obligation="normative">
@@ -236,10 +246,12 @@ RSpec.describe Asciidoctor::ISO do
236
246
  </sections>
237
247
  </iso-standard>
238
248
  OUTPUT
249
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
250
+ .to be_equivalent_to xmlpp(output)
239
251
  end
240
252
 
241
253
  it "processes terms & definitions with external source" do
242
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
254
+ input = <<~INPUT
243
255
  #{ASCIIDOC_BLANK_HDR}
244
256
 
245
257
  Foreword
@@ -250,6 +262,7 @@ RSpec.describe Asciidoctor::ISO do
250
262
  === Term1
251
263
 
252
264
  INPUT
265
+ output = <<~OUTPUT
253
266
  #{BLANK_HDR.sub(/<boilerplate>/, '<termdocsource bibitemid="iso1234"/><termdocsource bibitemid="iso5678"/><boilerplate>')}
254
267
  <preface>
255
268
  <foreword id="_" obligation="informative">
@@ -285,10 +298,12 @@ RSpec.describe Asciidoctor::ISO do
285
298
  </sections>
286
299
  </iso-standard>
287
300
  OUTPUT
301
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
302
+ .to be_equivalent_to xmlpp(output)
288
303
  end
289
304
 
290
305
  it "processes empty terms & definitions" do
291
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
306
+ input = <<~INPUT
292
307
  #{ASCIIDOC_BLANK_HDR}
293
308
 
294
309
  Foreword
@@ -297,6 +312,7 @@ RSpec.describe Asciidoctor::ISO do
297
312
 
298
313
 
299
314
  INPUT
315
+ output = <<~OUTPUT
300
316
  #{BLANK_HDR}
301
317
  <preface>
302
318
  <foreword id="_" obligation="informative">
@@ -331,10 +347,12 @@ RSpec.describe Asciidoctor::ISO do
331
347
  </iso-standard>
332
348
 
333
349
  OUTPUT
350
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
351
+ .to be_equivalent_to xmlpp(output)
334
352
  end
335
353
 
336
354
  it "processes empty terms & definitions with external source" do
337
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
355
+ input = <<~INPUT
338
356
  #{ASCIIDOC_BLANK_HDR}
339
357
 
340
358
  Foreword
@@ -343,6 +361,7 @@ RSpec.describe Asciidoctor::ISO do
343
361
  == Terms and Definitions
344
362
 
345
363
  INPUT
364
+ output = <<~OUTPUT
346
365
  #{BLANK_HDR.sub(/<boilerplate>/, '<termdocsource bibitemid="iso1234"/><termdocsource bibitemid="iso5678"/><boilerplate>')}
347
366
  <preface>
348
367
  <foreword id="_" obligation="informative">
@@ -375,5 +394,107 @@ RSpec.describe Asciidoctor::ISO do
375
394
  </sections>
376
395
  </iso-standard>
377
396
  OUTPUT
397
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
398
+ .to be_equivalent_to xmlpp(output)
399
+ end
400
+
401
+ it "ignores multiple terms & definitions in default documents" do
402
+ input = <<~INPUT
403
+ #{ASCIIDOC_BLANK_HDR}
404
+
405
+ == Terms and Definitions
406
+
407
+ == Clause
408
+
409
+ [heading=terms and definitions]
410
+ == More terms
411
+
412
+ INPUT
413
+ output = <<~OUTPUT
414
+ #{BLANK_HDR}
415
+ <sections>
416
+ <terms id='_' obligation='normative'>
417
+ <title>Terms and definitions</title>
418
+ <p id='_'>No terms and definitions are listed in this document.</p>
419
+ <p id='_'>
420
+ ISO and IEC maintain terminological databases for use in standardization
421
+ at the following addresses:
422
+ </p>
423
+ <ul id='_'>
424
+ <li>
425
+ <p id='_'>
426
+ ISO Online browsing platform: available at
427
+ <link target='http://www.iso.org/obp'/>
428
+ </p>
429
+ </li>
430
+ <li>
431
+ <p id='_'>
432
+ IEC Electropedia: available at
433
+ <link target='http://www.electropedia.org'/>
434
+ </p>
435
+ </li>
436
+ </ul>
437
+ </terms>
438
+ <clause id='_' inline-header='false' obligation='normative'>
439
+ <title>Clause</title>
440
+ </clause>
441
+ <clause id='_' inline-header='false' obligation='normative'>
442
+ <title>More terms</title>
443
+ </clause>
444
+ </sections>
445
+ </iso-standard>
446
+ OUTPUT
447
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
448
+ .to be_equivalent_to xmlpp(output)
449
+ end
450
+
451
+ it "permits multiple terms & definitions in vocabulary documents" do
452
+ input = <<~INPUT
453
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":nodoc:\n:docsubtype: vocabulary")}
454
+
455
+ == Terms and Definitions
456
+
457
+ == Clause
458
+
459
+ [heading=terms and definitions]
460
+ == More terms
461
+
462
+ INPUT
463
+ output = <<~OUTPUT
464
+ #{BLANK_HDR.sub(%r{<doctype>article</doctype>}, "<doctype>article</doctype><subdoctype>vocabulary</subdoctype>")}
465
+ <sections>
466
+ <terms id='_' obligation='normative'>
467
+ <title>Terms and definitions</title>
468
+ <p id='_'>No terms and definitions are listed in this document.</p>
469
+ <p id='_'>
470
+ ISO and IEC maintain terminological databases for use in standardization
471
+ at the following addresses:
472
+ </p>
473
+ <ul id='_'>
474
+ <li>
475
+ <p id='_'>
476
+ ISO Online browsing platform: available at
477
+ <link target='http://www.iso.org/obp'/>
478
+ </p>
479
+ </li>
480
+ <li>
481
+ <p id='_'>
482
+ IEC Electropedia: available at
483
+ <link target='http://www.electropedia.org'/>
484
+ </p>
485
+ </li>
486
+ </ul>
487
+ </terms>
488
+ <clause id='_' inline-header='false' obligation='normative'>
489
+ <title>Clause</title>
490
+ </clause>
491
+ <terms id='_' obligation='normative'>
492
+ <title>More terms</title>
493
+ </terms>
494
+ </sections>
495
+ </iso-standard>
496
+ OUTPUT
497
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
498
+ .to be_equivalent_to xmlpp(output)
378
499
  end
379
500
  end
@@ -802,6 +802,18 @@ RSpec.describe Asciidoctor::ISO do
802
802
  expect(File.read("test.err"))
803
803
  .to include "Symbols and Abbreviated Terms can only contain "\
804
804
  "a definition list"
805
+
806
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
807
+ #{VALIDATING_BLANK_HDR}
808
+
809
+ == Symbols and Abbreviated Terms
810
+
811
+ A:: B
812
+ INPUT
813
+ expect(File.read("test.err"))
814
+ .not_to include "Symbols and Abbreviated Terms can only contain "\
815
+ "a definition list"
816
+
805
817
  end
806
818
 
807
819
  it "Warning if missing foreword" do
@@ -1187,7 +1199,9 @@ RSpec.describe Asciidoctor::ISO do
1187
1199
  expect(File.read("test.err"))
1188
1200
  .not_to include "Only annexes and references can follow clauses"
1189
1201
  expect(File.read("test.err"))
1190
- .to include "Only terms, annexes and references can follow clauses"
1202
+ .not_to include "Scope must occur before Terms and Definitions"
1203
+ expect(File.read("test.err"))
1204
+ .to include "Only annexes and references can follow terms and clauses"
1191
1205
  end
1192
1206
 
1193
1207
 
@@ -1678,20 +1692,6 @@ RSpec.describe Asciidoctor::ISO do
1678
1692
  .not_to include "exceeds the maximum clause depth of 7"
1679
1693
  end
1680
1694
 
1681
- it "Warn if term citation in Terms & Definitions not preceded with italicised term" do
1682
- Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1683
- #{VALIDATING_BLANK_HDR}
1684
- == Terms and Definitions
1685
-
1686
- [[term]]
1687
- === Term
1688
-
1689
- The definition of a term (<<term>>) is a part of the specialized vocabulary of a particular field
1690
- INPUT
1691
- expect(File.read("test.err"))
1692
- .to include "term citation not preceded with italicised term"
1693
- end
1694
-
1695
1695
  it "Warn if an undated reference has no associated footnote" do
1696
1696
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1697
1697
  #{VALIDATING_BLANK_HDR}
@@ -87,7 +87,7 @@ RSpec.describe IsoDoc do
87
87
  </foreword>
88
88
  </preface>
89
89
  <sections>
90
- <clause id="scope" displayorder="3">
90
+ <clause id="scope" displayorder="2">
91
91
  <title depth="1">Scope</title>
92
92
  <note id="N">
93
93
  <name>NOTE</name>
@@ -99,7 +99,7 @@ RSpec.describe IsoDoc do
99
99
  <xref target="N">Note</xref>
100
100
  </p>
101
101
  </clause>
102
- <terms id="terms" displayorder="2"/>
102
+ <terms id="terms" displayorder="3"/>
103
103
  <clause id="widgets" displayorder="4">
104
104
  <title depth="1">Widgets</title>
105
105
  <clause id="widgets1" inline-header="true">
@@ -394,29 +394,30 @@ RSpec.describe IsoDoc do
394
394
  it "processes concept markup" do
395
395
  input = <<~INPUT
396
396
  <iso-standard xmlns="http://riboseinc.com/isoxml">
397
- <preface><foreword>
397
+ <sections>
398
+ <terms id="Terms">
398
399
  <p>
399
400
  <ul>
400
- <li><concept><refterm>term</refterm>
401
+ <li><concept><refterm>term0</refterm>
401
402
  <xref target='clause1'/>
402
403
  </concept></li>
403
- <li><concept><refterm>term</refterm>
404
+ <li><concept><refterm>term1</refterm>
404
405
  <renderterm>term</renderterm>
405
406
  <xref target='clause1'/>
406
407
  </concept></li>
407
- <li><concept><refterm>term</refterm>
408
+ <li><concept><refterm>term2</refterm>
408
409
  <renderterm>w[o]rd</renderterm>
409
410
  <xref target='clause1'>Clause #1</xref>
410
411
  </concept></li>
411
- <li><concept><refterm>term</refterm>
412
+ <li><concept><refterm>term3</refterm>
412
413
  <renderterm>term</renderterm>
413
414
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712"/>
414
415
  </concept></li>
415
- <li><concept><refterm>term</refterm>
416
+ <li><concept><refterm>term4</refterm>
416
417
  <renderterm>word</renderterm>
417
418
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712">The Aforementioned Citation</eref>
418
419
  </concept></li>
419
- <li><concept><refterm>term</refterm>
420
+ <li><concept><refterm>term5</refterm>
420
421
  <renderterm>word</renderterm>
421
422
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
422
423
  <locality type='clause'>
@@ -427,7 +428,7 @@ RSpec.describe IsoDoc do
427
428
  </locality>
428
429
  </eref>
429
430
  </concept></li>
430
- <li><concept><refterm>term</refterm>
431
+ <li><concept><refterm>term6</refterm>
431
432
  <renderterm>word</renderterm>
432
433
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
433
434
  <localityStack>
@@ -442,7 +443,7 @@ RSpec.describe IsoDoc do
442
443
  </localityStack>
443
444
  </eref>
444
445
  </concept></li>
445
- <li><concept><refterm>term</refterm>
446
+ <li><concept><refterm>term7</refterm>
446
447
  <renderterm>word</renderterm>
447
448
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
448
449
  <localityStack>
@@ -458,18 +459,21 @@ RSpec.describe IsoDoc do
458
459
  The Aforementioned Citation
459
460
  </eref>
460
461
  </concept></li>
461
- <li><concept><refterm>term</refterm>
462
+ <li><concept><refterm>term8</refterm>
462
463
  <renderterm>word</renderterm>
463
464
  <termref base='IEV' target='135-13-13'/>
464
465
  </concept></li>
465
- <li><concept><refterm>term</refterm>
466
+ <li><concept><refterm>term9</refterm>
466
467
  <renderterm>word</renderterm>
467
468
  <termref base='IEV' target='135-13-13'>The IEV database</termref>
468
469
  </concept></li>
470
+ <li><concept><refterm>term10</refterm>
471
+ <renderterm>word</renderterm>
472
+ <strong>error!</strong>
473
+ </concept></li>
469
474
  </ul>
470
475
  </p>
471
- </foreword></preface>
472
- <sections>
476
+ </terms>
473
477
  <clause id="clause1"><title>Clause 1</title></clause>
474
478
  </sections>
475
479
  <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
@@ -489,111 +493,129 @@ RSpec.describe IsoDoc do
489
493
  </iso-standard>
490
494
  INPUT
491
495
  presxml = <<~OUTPUT
492
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
493
- <preface><foreword displayorder="1">
494
- <p>
495
- <ul>
496
- <li>
497
- (<xref target="clause1">Clause 2</xref>)
498
- </li>
499
- <li>
500
- <em>term</em>
501
- (<xref target="clause1">Clause 2</xref>)
502
- </li>
503
- <li>
504
- <em>w[o]rd</em>
505
- (<xref target="clause1">Clause #1</xref>)
506
- </li>
507
- <li>
508
- <em>term</em>
509
- (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">ISO 712</eref>)
510
- </li>
511
- <li>
512
- <em>word</em>
513
- (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">The Aforementioned Citation</eref>)
514
- </li>
515
- <li>
516
- <em>word</em>
517
- (<eref bibitemid="ISO712" type="inline" citeas="ISO 712"><locality type="clause">
518
- <referenceFrom>3.1</referenceFrom>
519
- </locality><locality type="figure">
520
- <referenceFrom>a</referenceFrom>
521
- </locality>ISO 712, 3.1, Figure a</eref>)
522
- </li>
523
- <li>
524
- <em>word</em>
525
- (<eref bibitemid="ISO712" type="inline" citeas="ISO 712"><localityStack>
526
- <locality type="clause">
527
- <referenceFrom>3.1</referenceFrom>
528
- </locality>
529
- </localityStack><localityStack>
530
- <locality type="figure">
531
- <referenceFrom>b</referenceFrom>
532
- </locality>
533
- </localityStack>ISO 712, 3.1; Figure b</eref>)
534
- </li>
535
- <li>
536
- <em>word</em>
537
- (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">
538
- <localityStack>
539
- <locality type="clause">
540
- <referenceFrom>3.1</referenceFrom>
541
- </locality>
542
- </localityStack>
543
- <localityStack>
544
- <locality type="figure">
545
- <referenceFrom>b</referenceFrom>
546
- </locality>
547
- </localityStack>
548
- The Aforementioned Citation
549
- </eref>)
550
- </li>
551
- <li>
552
- <em>word</em>
553
- [term defined in <termref base="IEV" target="135-13-13"/>]
554
- </li>
555
- <li>
556
- <em>word</em>
557
- [term defined in <termref base="IEV" target="135-13-13">The IEV database</termref>]
558
- </li>
559
- </ul>
560
- </p>
561
- </foreword></preface>
562
- <sections>
563
- <clause id="clause1" displayorder="3"><title depth="1">2<tab/>Clause 1</title></clause>
564
- </sections>
565
- <bibliography><references id="_normative_references" obligation="informative" normative="true" displayorder="2"><title depth="1">1<tab/>Normative References</title>
566
- <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
567
- <bibitem id="ISO712" type="standard">
568
- <title format="text/plain">Cereals or cereal products</title>
569
- <title type="main" format="text/plain">Cereals and cereal products</title>
570
- <docidentifier type="ISO">ISO 712</docidentifier>
571
- <contributor>
572
- <role type="publisher"/>
573
- <organization>
574
- <name>International Organization for Standardization</name>
575
- </organization>
576
- </contributor>
577
- </bibitem>
578
- </references></bibliography>
579
- </iso-standard>
496
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
497
+ <sections>
498
+ <terms id="Terms" displayorder="2"><title>2</title>
499
+ <p>
500
+ <ul>
501
+ <li>
502
+ (<xref target="clause1">Clause 3</xref>)
503
+ </li>
504
+ <li>
505
+ <em>term</em>
506
+ (<xref target="clause1">Clause 3</xref>)
507
+ </li>
508
+ <li>
509
+ <em>w[o]rd</em>
510
+ (<xref target="clause1">Clause #1</xref>)
511
+ </li>
512
+ <li>
513
+ <em>term</em>
514
+ (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">ISO 712</eref>)
515
+ </li>
516
+ <li>
517
+ <em>word</em>
518
+ (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">The Aforementioned Citation</eref>)
519
+ </li>
520
+ <li>
521
+ <em>word</em>
522
+ (<eref bibitemid="ISO712" type="inline" citeas="ISO 712"><locality type="clause">
523
+ <referenceFrom>3.1</referenceFrom>
524
+ </locality><locality type="figure">
525
+ <referenceFrom>a</referenceFrom>
526
+ </locality>ISO 712, 3.1, Figure a</eref>)
527
+ </li>
528
+ <li>
529
+ <em>word</em>
530
+ (<eref bibitemid="ISO712" type="inline" citeas="ISO 712"><localityStack>
531
+ <locality type="clause">
532
+ <referenceFrom>3.1</referenceFrom>
533
+ </locality>
534
+ </localityStack><localityStack>
535
+ <locality type="figure">
536
+ <referenceFrom>b</referenceFrom>
537
+ </locality>
538
+ </localityStack>ISO 712, 3.1; Figure b</eref>)
539
+ </li>
540
+ <li>
541
+ <em>word</em>
542
+ (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">
543
+ <localityStack>
544
+ <locality type="clause">
545
+ <referenceFrom>3.1</referenceFrom>
546
+ </locality>
547
+ </localityStack>
548
+ <localityStack>
549
+ <locality type="figure">
550
+ <referenceFrom>b</referenceFrom>
551
+ </locality>
552
+ </localityStack>
553
+ The Aforementioned Citation
554
+ </eref>)
555
+ </li>
556
+ <li>
557
+ <em>word</em>
558
+ [term defined in <termref base="IEV" target="135-13-13"/>]
559
+ </li>
560
+ <li>
561
+ <em>word</em>
562
+ [term defined in <termref base="IEV" target="135-13-13">The IEV database</termref>]
563
+ </li>
564
+ <li>
565
+ <em>word</em>
566
+ <strong>error!</strong>
567
+ </li>
568
+ </ul>
569
+ </p>
570
+ </terms>
571
+ <clause id="clause1" displayorder="3"><title depth="1">3<tab/>Clause 1</title></clause>
572
+ </sections>
573
+ <bibliography><references id="_normative_references" obligation="informative" normative="true" displayorder="1"><title depth="1">1<tab/>Normative References</title>
574
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
575
+ <bibitem id="ISO712" type="standard">
576
+ <title format="text/plain">Cereals or cereal products</title>
577
+ <title type="main" format="text/plain">Cereals and cereal products</title>
578
+ <docidentifier type="ISO">ISO 712</docidentifier>
579
+ <contributor>
580
+ <role type="publisher"/>
581
+ <organization>
582
+ <name>International Organization for Standardization</name>
583
+ </organization>
584
+ </contributor>
585
+ </bibitem>
586
+ </references></bibliography>
587
+ </iso-standard>
580
588
  OUTPUT
581
589
  output = <<~OUTPUT
582
590
  #{HTML_HDR}
583
- <br/>
591
+ <p class='zzSTDTitle1'/>
584
592
  <div>
585
- <h1 class='ForewordTitle'>Foreword</h1>
593
+ <h1>1&#160; Normative References</h1>
594
+ <p>
595
+ The following documents are referred to in the text in such a way that
596
+ some or all of their content constitutes requirements of this
597
+ document. For dated references, only the edition cited applies. For
598
+ undated references, the latest edition of the referenced document
599
+ (including any amendments) applies.
600
+ </p>
601
+ <p id='ISO712' class='NormRef'>
602
+ ISO 712,
603
+ <i>Cereals and cereal products</i>
604
+ </p>
605
+ </div>
606
+ <div id='Terms'>
607
+ <h1>2</h1>
586
608
  <p>
587
609
  <ul>
588
610
  <li>
589
611
  (
590
- <a href='#clause1'>Clause 2</a>
612
+ <a href='#clause1'>Clause 3</a>
591
613
  )
592
614
  </li>
593
615
  <li>
594
616
  <i>term</i>
595
617
  (
596
- <a href='#clause1'>Clause 2</a>
618
+ <a href='#clause1'>Clause 3</a>
597
619
  )
598
620
  </li>
599
621
  <li>
@@ -638,28 +660,17 @@ RSpec.describe IsoDoc do
638
660
  </li>
639
661
  <li>
640
662
  <i>word</i>
641
- [term defined in Termbase IEV, term ID 135-13-13]
663
+ [term defined in The IEV database]
664
+ </li>
665
+ <li>
666
+ <i>word</i>
667
+ <b>error!</b>
642
668
  </li>
643
669
  </ul>
644
670
  </p>
645
671
  </div>
646
- <p class='zzSTDTitle1'/>
647
- <div>
648
- <h1>1&#160; Normative References</h1>
649
- <p>
650
- The following documents are referred to in the text in such a way that
651
- some or all of their content constitutes requirements of this
652
- document. For dated references, only the edition cited applies. For
653
- undated references, the latest edition of the referenced document
654
- (including any amendments) applies.
655
- </p>
656
- <p id='ISO712' class='NormRef'>
657
- ISO 712,
658
- <i>Cereals and cereal products</i>
659
- </p>
660
- </div>
661
672
  <div id='clause1'>
662
- <h1>2&#160; Clause 1</h1>
673
+ <h1>3&#160; Clause 1</h1>
663
674
  </div>
664
675
  </div>
665
676
  </body>
@@ -670,4 +681,183 @@ RSpec.describe IsoDoc do
670
681
  expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({})
671
682
  .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
672
683
  end
684
+
685
+ it "processes concept markup by context" do
686
+ input = <<~INPUT
687
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
688
+ <preface><foreword id="A">
689
+ <ul>
690
+ <li><concept><refterm>term1</refterm>
691
+ <renderterm>term</renderterm>
692
+ <xref target='clause1'/>
693
+ </concept></li>
694
+ </ul>
695
+ </foreword></preface>
696
+ <sections>
697
+ <terms id="Terms">
698
+ <term id="clause1">
699
+ <ul>
700
+ <li><concept><refterm>term1</refterm>
701
+ <renderterm>term</renderterm>
702
+ <xref target='clause1'/>
703
+ </concept></li>
704
+ <li><concept><refterm>term1</refterm>
705
+ <renderterm>term</renderterm>
706
+ <xref target='clause1'/>
707
+ </concept></li>
708
+ </ul>
709
+ </term>
710
+ </terms>
711
+ </sections>
712
+ </iso-standard>
713
+ INPUT
714
+ presxml = <<~OUTPUT
715
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
716
+ <preface>
717
+ <foreword id='A' displayorder='1'>
718
+ <ul>
719
+ <li>term</li>
720
+ </ul>
721
+ </foreword>
722
+ </preface>
723
+ <sections>
724
+ <terms id='Terms' displayorder='2'>
725
+ <title>1</title>
726
+ <term id='clause1'>
727
+ <name>1.1</name>
728
+ <ul>
729
+ <li>
730
+ <em>term</em>
731
+ (
732
+ <xref target='clause1'>1.1</xref>
733
+ )
734
+ </li>
735
+ <li>term</li>
736
+ </ul>
737
+ </term>
738
+ </terms>
739
+ </sections>
740
+ </iso-standard>
741
+ OUTPUT
742
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
743
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
744
+ end
745
+
746
+ it "processes concept attributes" do
747
+ input = <<~INPUT
748
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
749
+ <sections>
750
+ <clause id="clause1"><title>Clause 1</title></clause>
751
+ <terms id="A">
752
+ <p>
753
+ <ul>
754
+ <li>
755
+ <concept ital="true"><refterm>term</refterm>
756
+ <renderterm>term</renderterm>
757
+ <xref target='clause1'/>
758
+ </concept></li>
759
+ <li><concept ref="true"><refterm>term</refterm>
760
+ <renderterm>term</renderterm>
761
+ <xref target='clause1'/>
762
+ </concept></li>
763
+ <li><concept ital="true" ref="true"><refterm>term</refterm>
764
+ <renderterm>term</renderterm>
765
+ <xref target='clause1'/>
766
+ </concept></li>
767
+ <li><concept ital="false"><refterm>term</refterm>
768
+ <renderterm>term</renderterm>
769
+ <xref target='clause1'/>
770
+ </concept></li>
771
+ <li><concept ref="false"><refterm>term</refterm>
772
+ <renderterm>term</renderterm>
773
+ <xref target='clause1'/>
774
+ </concept></li>
775
+ <li><concept ital="false" ref="false"><refterm>term</refterm>
776
+ <renderterm>term</renderterm>
777
+ <xref target='clause1'/>
778
+ </concept></li>
779
+ </ul></p>
780
+ </terms>
781
+ </sections>
782
+ </iso-standard>
783
+ INPUT
784
+ presxml = <<~OUTPUT
785
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
786
+ <sections>
787
+ <clause id="clause1" displayorder="1"><title depth="1">1<tab/>Clause 1</title></clause>
788
+ <terms id="A" displayorder="2"><title>2</title>
789
+ <p>
790
+ <ul>
791
+ <li>
792
+
793
+ <em>term</em>
794
+ (<xref target="clause1">Clause 1</xref>)
795
+ </li>
796
+ <li>
797
+ term
798
+ (<xref target="clause1">Clause 1</xref>)
799
+ </li>
800
+ <li>
801
+ <em>term</em>
802
+ (<xref target="clause1">Clause 1</xref>)
803
+ </li>
804
+ <li>
805
+ term
806
+
807
+ </li>
808
+ <li>
809
+ term
810
+
811
+ </li>
812
+ <li>
813
+ term
814
+
815
+ </li>
816
+ </ul></p>
817
+ </terms>
818
+ </sections>
819
+ </iso-standard>
820
+ OUTPUT
821
+ output = <<~OUTPUT
822
+ #{HTML_HDR}
823
+ <p class='zzSTDTitle1'/>
824
+ <div id='clause1'>
825
+ <h1>1&#160; Clause 1</h1>
826
+ </div>
827
+ <div id='A'>
828
+ <h1>2</h1>
829
+ <p>
830
+ <ul>
831
+ <li>
832
+ <i>term</i>
833
+ (
834
+ <a href='#clause1'>Clause 1</a>
835
+ )
836
+ </li>
837
+ <li>
838
+ term (
839
+ <a href='#clause1'>Clause 1</a>
840
+ )
841
+ </li>
842
+ <li>
843
+ <i>term</i>
844
+ (
845
+ <a href='#clause1'>Clause 1</a>
846
+ )
847
+ </li>
848
+ <li> term </li>
849
+ <li> term </li>
850
+ <li> term </li>
851
+ </ul>
852
+ </p>
853
+ </div>
854
+ </div>
855
+ </body>
856
+ </html>
857
+ OUTPUT
858
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
859
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
860
+ expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({})
861
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
862
+ end
673
863
  end