metanorma-iso 1.8.6 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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