metanorma-iso 1.8.5 → 1.9.1

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">
@@ -390,4 +390,474 @@ RSpec.describe IsoDoc do
390
390
  </iso-standard>
391
391
  OUTPUT
392
392
  end
393
+
394
+ it "processes concept markup" do
395
+ input = <<~INPUT
396
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
397
+ <sections>
398
+ <terms id="Terms">
399
+ <p>
400
+ <ul>
401
+ <li><concept><refterm>term0</refterm>
402
+ <xref target='clause1'/>
403
+ </concept></li>
404
+ <li><concept><refterm>term1</refterm>
405
+ <renderterm>term</renderterm>
406
+ <xref target='clause1'/>
407
+ </concept></li>
408
+ <li><concept><refterm>term2</refterm>
409
+ <renderterm>w[o]rd</renderterm>
410
+ <xref target='clause1'>Clause #1</xref>
411
+ </concept></li>
412
+ <li><concept><refterm>term3</refterm>
413
+ <renderterm>term</renderterm>
414
+ <eref bibitemid="ISO712" type="inline" citeas="ISO 712"/>
415
+ </concept></li>
416
+ <li><concept><refterm>term4</refterm>
417
+ <renderterm>word</renderterm>
418
+ <eref bibitemid="ISO712" type="inline" citeas="ISO 712">The Aforementioned Citation</eref>
419
+ </concept></li>
420
+ <li><concept><refterm>term5</refterm>
421
+ <renderterm>word</renderterm>
422
+ <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
423
+ <locality type='clause'>
424
+ <referenceFrom>3.1</referenceFrom>
425
+ </locality>
426
+ <locality type='figure'>
427
+ <referenceFrom>a</referenceFrom>
428
+ </locality>
429
+ </eref>
430
+ </concept></li>
431
+ <li><concept><refterm>term6</refterm>
432
+ <renderterm>word</renderterm>
433
+ <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
434
+ <localityStack>
435
+ <locality type='clause'>
436
+ <referenceFrom>3.1</referenceFrom>
437
+ </locality>
438
+ </localityStack>
439
+ <localityStack>
440
+ <locality type='figure'>
441
+ <referenceFrom>b</referenceFrom>
442
+ </locality>
443
+ </localityStack>
444
+ </eref>
445
+ </concept></li>
446
+ <li><concept><refterm>term7</refterm>
447
+ <renderterm>word</renderterm>
448
+ <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
449
+ <localityStack>
450
+ <locality type='clause'>
451
+ <referenceFrom>3.1</referenceFrom>
452
+ </locality>
453
+ </localityStack>
454
+ <localityStack>
455
+ <locality type='figure'>
456
+ <referenceFrom>b</referenceFrom>
457
+ </locality>
458
+ </localityStack>
459
+ The Aforementioned Citation
460
+ </eref>
461
+ </concept></li>
462
+ <li><concept><refterm>term8</refterm>
463
+ <renderterm>word</renderterm>
464
+ <termref base='IEV' target='135-13-13'/>
465
+ </concept></li>
466
+ <li><concept><refterm>term9</refterm>
467
+ <renderterm>word</renderterm>
468
+ <termref base='IEV' target='135-13-13'>The IEV database</termref>
469
+ </concept></li>
470
+ <li><concept><refterm>term10</refterm>
471
+ <renderterm>word</renderterm>
472
+ <strong>error!</strong>
473
+ </concept></li>
474
+ </ul>
475
+ </p>
476
+ </terms>
477
+ <clause id="clause1"><title>Clause 1</title></clause>
478
+ </sections>
479
+ <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
480
+ <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>
481
+ <bibitem id="ISO712" type="standard">
482
+ <title format="text/plain">Cereals or cereal products</title>
483
+ <title type="main" format="text/plain">Cereals and cereal products</title>
484
+ <docidentifier type="ISO">ISO 712</docidentifier>
485
+ <contributor>
486
+ <role type="publisher"/>
487
+ <organization>
488
+ <name>International Organization for Standardization</name>
489
+ </organization>
490
+ </contributor>
491
+ </bibitem>
492
+ </references></bibliography>
493
+ </iso-standard>
494
+ INPUT
495
+ presxml = <<~OUTPUT
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>
588
+ OUTPUT
589
+ output = <<~OUTPUT
590
+ #{HTML_HDR}
591
+ <p class='zzSTDTitle1'/>
592
+ <div>
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>
608
+ <p>
609
+ <ul>
610
+ <li>
611
+ (
612
+ <a href='#clause1'>Clause 3</a>
613
+ )
614
+ </li>
615
+ <li>
616
+ <i>term</i>
617
+ (
618
+ <a href='#clause1'>Clause 3</a>
619
+ )
620
+ </li>
621
+ <li>
622
+ <i>w[o]rd</i>
623
+ (
624
+ <a href='#clause1'>Clause #1</a>
625
+ )
626
+ </li>
627
+ <li>
628
+ <i>term</i>
629
+ (
630
+ <a href='#ISO712'>ISO 712</a>
631
+ )
632
+ </li>
633
+ <li>
634
+ <i>word</i>
635
+ (
636
+ <a href='#ISO712'>The Aforementioned Citation</a>
637
+ )
638
+ </li>
639
+ <li>
640
+ <i>word</i>
641
+ (
642
+ <a href='#ISO712'>ISO 712, 3.1, Figure a</a>
643
+ )
644
+ </li>
645
+ <li>
646
+ <i>word</i>
647
+ (
648
+ <a href='#ISO712'>ISO 712, 3.1; Figure b</a>
649
+ )
650
+ </li>
651
+ <li>
652
+ <i>word</i>
653
+ (
654
+ <a href='#ISO712'> The Aforementioned Citation </a>
655
+ )
656
+ </li>
657
+ <li>
658
+ <i>word</i>
659
+ [term defined in Termbase IEV, term ID 135-13-13]
660
+ </li>
661
+ <li>
662
+ <i>word</i>
663
+ [term defined in The IEV database]
664
+ </li>
665
+ <li>
666
+ <i>word</i>
667
+ <b>error!</b>
668
+ </li>
669
+ </ul>
670
+ </p>
671
+ </div>
672
+ <div id='clause1'>
673
+ <h1>3&#160; Clause 1</h1>
674
+ </div>
675
+ </div>
676
+ </body>
677
+ </html>
678
+ OUTPUT
679
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
680
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
681
+ expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({})
682
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
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
393
863
  end