metanorma-iso 1.8.4 → 1.9.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -1
  3. data/.rubocop.yml +1 -1
  4. data/lib/asciidoctor/iso/cleanup.rb +0 -1
  5. data/lib/asciidoctor/iso/isodoc.rng +50 -8
  6. data/lib/asciidoctor/iso/isostandard.rng +7 -3
  7. data/lib/asciidoctor/iso/section.rb +3 -0
  8. data/lib/asciidoctor/iso/validate.rb +4 -17
  9. data/lib/asciidoctor/iso/validate_section.rb +50 -34
  10. data/lib/asciidoctor/iso/validate_style.rb +3 -3
  11. data/lib/isodoc/iso/base_convert.rb +41 -16
  12. data/lib/isodoc/iso/html/isodoc.css +475 -20
  13. data/lib/isodoc/iso/html/isodoc.scss +456 -23
  14. data/lib/isodoc/iso/html/wordstyle.css +202 -31
  15. data/lib/isodoc/iso/html/wordstyle.scss +194 -32
  16. data/lib/isodoc/iso/iso.amendment.xsl +480 -388
  17. data/lib/isodoc/iso/iso.international-standard.xsl +480 -388
  18. data/lib/isodoc/iso/isosts_convert.rb +12 -13
  19. data/lib/isodoc/iso/metadata.rb +2 -2
  20. data/lib/isodoc/iso/presentation_xml_convert.rb +62 -9
  21. data/lib/isodoc/iso/sts_convert.rb +4 -5
  22. data/lib/isodoc/iso/word_convert.rb +153 -39
  23. data/lib/isodoc/iso/xref.rb +17 -1
  24. data/lib/metanorma/iso/version.rb +1 -1
  25. data/metanorma-iso.gemspec +4 -4
  26. data/spec/asciidoctor/section_spec.rb +128 -7
  27. data/spec/asciidoctor/validate_spec.rb +15 -15
  28. data/spec/isodoc/amd_spec.rb +193 -201
  29. data/spec/isodoc/blocks_spec.rb +100 -88
  30. data/spec/isodoc/i18n_spec.rb +36 -36
  31. data/spec/isodoc/inline_spec.rb +472 -2
  32. data/spec/isodoc/iso_spec.rb +86 -138
  33. data/spec/isodoc/postproc_spec.rb +19 -10
  34. data/spec/isodoc/ref_spec.rb +6 -6
  35. data/spec/isodoc/section_spec.rb +394 -276
  36. data/spec/isodoc/table_spec.rb +166 -231
  37. data/spec/isodoc/terms_spec.rb +11 -8
  38. data/spec/isodoc/xref_spec.rb +147 -118
  39. metadata +8 -8
@@ -318,7 +318,7 @@ RSpec.describe IsoDoc do
318
318
  <?xml version='1.0'?>
319
319
  <iso-standard type="presentation" xmlns="http://riboseinc.com/isoxml">
320
320
  <preface>
321
- <foreword>
321
+ <foreword displayorder="1">
322
322
  <p>
323
323
  <eref bibitemid="IEV" citeas="IEV" type="inline">
324
324
  <locality type="clause">
@@ -372,7 +372,7 @@ RSpec.describe IsoDoc do
372
372
  </foreword>
373
373
  </preface>
374
374
  <bibliography>
375
- <references id="_normative_references" normative="true" obligation="informative">
375
+ <references id="_normative_references" normative="true" obligation="informative" displayorder="2">
376
376
  <title depth="1">1<tab/>
377
377
  Normative References</title>
378
378
  <bibitem id="ISO712" type="standard">
@@ -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