metanorma-iso 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -2
- data/lib/asciidoctor/iso/base.rb +1 -0
- data/lib/asciidoctor/iso/cleanup.rb +17 -5
- data/lib/asciidoctor/iso/front.rb +3 -1
- data/lib/asciidoctor/iso/front_id.rb +66 -50
- data/lib/asciidoctor/iso/isodoc.rng +174 -0
- data/lib/asciidoctor/iso/isostandard.rng +1 -0
- data/lib/asciidoctor/iso/section.rb +2 -1
- data/lib/isodoc/iso/iso.amendment.xsl +65 -0
- data/lib/isodoc/iso/iso.international-standard.xsl +65 -0
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/sts_convert.rb +10 -13
- data/lib/isodoc/iso/xref.rb +31 -18
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +1 -1
- data/spec/asciidoctor/base_spec.rb +426 -334
- data/spec/asciidoctor/cleanup_spec.rb +383 -25
- data/spec/asciidoctor/section_spec.rb +0 -14
- data/spec/asciidoctor/validate_spec.rb +72 -39
- data/spec/isodoc/postproc_spec.rb +475 -434
- metadata +4 -4
@@ -101,20 +101,6 @@ RSpec.describe Asciidoctor::ISO do
|
|
101
101
|
<title>Terms, definitions, symbols and abbreviated terms</title>
|
102
102
|
<terms id="_" obligation="normative">
|
103
103
|
<title>Normal Terms</title>
|
104
|
-
<p id="_">For the purposes of this document, the following terms and definitions apply.</p>
|
105
|
-
<p id="_">ISO and IEC maintain terminological databases for use in standardization at the following addresses:</p>
|
106
|
-
<ul id="_">
|
107
|
-
<li>
|
108
|
-
<p id="_">ISO Online browsing platform: available at
|
109
|
-
|
110
|
-
<link target="http://www.iso.org/obp"/></p>
|
111
|
-
</li>
|
112
|
-
<li>
|
113
|
-
<p id="_">IEC Electropedia: available at
|
114
|
-
|
115
|
-
<link target="http://www.electropedia.org"/></p>
|
116
|
-
</li>
|
117
|
-
</ul>
|
118
104
|
<term id="term-term2">
|
119
105
|
<preferred>Term2</preferred>
|
120
106
|
</term>
|
@@ -517,7 +517,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
517
517
|
<<iso123>>
|
518
518
|
INPUT
|
519
519
|
expect(File.read("test.err"))
|
520
|
-
.to include "iso123 does not have a corresponding anchor ID
|
520
|
+
.to include "iso123 does not have a corresponding anchor ID "\
|
521
|
+
"in the bibliography"
|
521
522
|
end
|
522
523
|
|
523
524
|
it "warns that undated reference has locality" do
|
@@ -530,9 +531,10 @@ RSpec.describe Asciidoctor::ISO do
|
|
530
531
|
[bibliography]
|
531
532
|
== Normative References
|
532
533
|
* [[[iso123,ISO 123]]] _Standard_
|
533
|
-
|
534
|
-
|
535
|
-
|
534
|
+
INPUT
|
535
|
+
expect(File.read("test.err"))
|
536
|
+
.to include "undated reference ISO 123 should not contain "\
|
537
|
+
"specific elements"
|
536
538
|
end
|
537
539
|
|
538
540
|
it "do not warn that undated reference which is a bibliographic reference has locality" do
|
@@ -545,9 +547,10 @@ RSpec.describe Asciidoctor::ISO do
|
|
545
547
|
[bibliography]
|
546
548
|
== Bibliography
|
547
549
|
* [[[iso123,1]]] _Standard_
|
548
|
-
|
549
|
-
|
550
|
-
|
550
|
+
INPUT
|
551
|
+
expect(File.read("test.err"))
|
552
|
+
.not_to include "undated reference [1] should not contain specific "\
|
553
|
+
"elements"
|
551
554
|
end
|
552
555
|
|
553
556
|
it "do not warn that undated IEV reference has locality" do
|
@@ -560,9 +563,10 @@ RSpec.describe Asciidoctor::ISO do
|
|
560
563
|
[bibliography]
|
561
564
|
== Normative References
|
562
565
|
* [[[iev,IEV]]] _Standard_
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
+
INPUT
|
567
|
+
expect(File.read("test.err"))
|
568
|
+
.not_to include "undated reference IEV should not contain specific "\
|
569
|
+
"elements"
|
566
570
|
end
|
567
571
|
|
568
572
|
it "do not warn that in print has locality" do
|
@@ -575,8 +579,10 @@ RSpec.describe Asciidoctor::ISO do
|
|
575
579
|
[bibliography]
|
576
580
|
== Normative References
|
577
581
|
* [[[iev,ISO 123:--]]] _Standard_
|
578
|
-
|
579
|
-
|
582
|
+
INPUT
|
583
|
+
expect(File.read("test.err"))
|
584
|
+
.not_to include "undated reference ISO 123 should not contain specific "\
|
585
|
+
"elements"
|
580
586
|
end
|
581
587
|
|
582
588
|
it "warns of Non-reference in bibliography" do
|
@@ -641,7 +647,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
641
647
|
== Clause
|
642
648
|
ISO 12121
|
643
649
|
INPUT
|
644
|
-
expect(File.read("test.err"))
|
650
|
+
expect(File.read("test.err"))
|
651
|
+
.not_to include "number not broken up in threes"
|
645
652
|
end
|
646
653
|
|
647
654
|
it "Style warning if decimal point" do
|
@@ -681,7 +688,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
681
688
|
== Clause
|
682
689
|
95 ± 5 %
|
683
690
|
INPUT
|
684
|
-
expect(File.read("test.err"))
|
691
|
+
expect(File.read("test.err"))
|
692
|
+
.to include "unbracketed tolerance before percent sign"
|
685
693
|
end
|
686
694
|
|
687
695
|
it "Style warning if dots in abbreviation" do
|
@@ -721,7 +729,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
721
729
|
== Clause
|
722
730
|
5 °
|
723
731
|
INPUT
|
724
|
-
expect(File.read("test.err"))
|
732
|
+
expect(File.read("test.err"))
|
733
|
+
.to include "space between number and degrees/minutes/seconds"
|
725
734
|
end
|
726
735
|
|
727
736
|
it "Style warning if no space between number and SI unit" do
|
@@ -731,7 +740,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
731
740
|
== Clause
|
732
741
|
A measurement of 5Bq was taken.
|
733
742
|
INPUT
|
734
|
-
expect(File.read("test.err"))
|
743
|
+
expect(File.read("test.err"))
|
744
|
+
.to include "no space between number and SI unit"
|
735
745
|
end
|
736
746
|
|
737
747
|
it "Style warning if mins used" do
|
@@ -777,7 +787,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
777
787
|
== Symbols and Abbreviated Terms
|
778
788
|
INPUT
|
779
789
|
expect(File.read("test.err"))
|
780
|
-
.to include "Only one Symbols and Abbreviated Terms section
|
790
|
+
.to include "Only one Symbols and Abbreviated Terms section "\
|
791
|
+
"in the standard"
|
781
792
|
end
|
782
793
|
|
783
794
|
it "Style warning if Symbols and Abbreviated Terms contains extraneous matter" do
|
@@ -789,7 +800,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
789
800
|
Paragraph
|
790
801
|
INPUT
|
791
802
|
expect(File.read("test.err"))
|
792
|
-
.to include "Symbols and Abbreviated Terms can only contain
|
803
|
+
.to include "Symbols and Abbreviated Terms can only contain "\
|
804
|
+
"a definition list"
|
793
805
|
end
|
794
806
|
|
795
807
|
it "Warning if missing foreword" do
|
@@ -902,7 +914,9 @@ RSpec.describe Asciidoctor::ISO do
|
|
902
914
|
|
903
915
|
Paragraph
|
904
916
|
INPUT
|
905
|
-
expect(File.read("test.err"))
|
917
|
+
expect(File.read("test.err"))
|
918
|
+
.to include "Normative References must be followed by "\
|
919
|
+
"Terms and Definitions"
|
906
920
|
|
907
921
|
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
908
922
|
= Document title
|
@@ -924,7 +938,9 @@ RSpec.describe Asciidoctor::ISO do
|
|
924
938
|
|
925
939
|
Paragraph
|
926
940
|
INPUT
|
927
|
-
expect(File.read("test.err"))
|
941
|
+
expect(File.read("test.err"))
|
942
|
+
.not_to include "Normative References must be followed by "\
|
943
|
+
"Terms and Definitions"
|
928
944
|
end
|
929
945
|
|
930
946
|
it "Warning if there are no clauses in the document" do
|
@@ -944,7 +960,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
944
960
|
== Symbols and Abbreviated Terms
|
945
961
|
|
946
962
|
INPUT
|
947
|
-
expect(File.read("test.err"))
|
963
|
+
expect(File.read("test.err"))
|
964
|
+
.to include "Document must contain at least one clause"
|
948
965
|
|
949
966
|
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
950
967
|
= Document title
|
@@ -967,7 +984,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
967
984
|
== Symbols and Abbreviated Terms
|
968
985
|
|
969
986
|
INPUT
|
970
|
-
expect(File.read("test.err"))
|
987
|
+
expect(File.read("test.err"))
|
988
|
+
.not_to include "Document must contain at least one clause"
|
971
989
|
end
|
972
990
|
|
973
991
|
it "Warning if scope occurs after Terms and Definitions" do
|
@@ -989,7 +1007,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
989
1007
|
== Scope
|
990
1008
|
|
991
1009
|
INPUT
|
992
|
-
expect(File.read("test.err"))
|
1010
|
+
expect(File.read("test.err"))
|
1011
|
+
.to include "Scope must occur before Terms and Definitions"
|
993
1012
|
|
994
1013
|
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
995
1014
|
= Document title
|
@@ -1014,7 +1033,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1014
1033
|
== Scope
|
1015
1034
|
|
1016
1035
|
INPUT
|
1017
|
-
expect(File.read("test.err"))
|
1036
|
+
expect(File.read("test.err"))
|
1037
|
+
.not_to include "Scope must occur before Terms and Definitions"
|
1018
1038
|
end
|
1019
1039
|
|
1020
1040
|
it "Warning if Symbols and Abbreviated Terms does not occur immediately after Terms and Definitions" do
|
@@ -1036,7 +1056,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1036
1056
|
== Symbols and Abbreviated Terms
|
1037
1057
|
|
1038
1058
|
INPUT
|
1039
|
-
expect(File.read("test.err"))
|
1059
|
+
expect(File.read("test.err"))
|
1060
|
+
.to include "Only annexes and references can follow clauses"
|
1040
1061
|
|
1041
1062
|
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
1042
1063
|
= Document title
|
@@ -1062,7 +1083,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1062
1083
|
== Symbols and Abbreviated Terms
|
1063
1084
|
|
1064
1085
|
INPUT
|
1065
|
-
expect(File.read("test.err"))
|
1086
|
+
expect(File.read("test.err"))
|
1087
|
+
.not_to include "Only annexes and references can follow clauses"
|
1066
1088
|
end
|
1067
1089
|
|
1068
1090
|
it "Warning if no normative references" do
|
@@ -1088,7 +1110,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1088
1110
|
== Appendix C
|
1089
1111
|
|
1090
1112
|
INPUT
|
1091
|
-
expect(File.read("test.err"))
|
1113
|
+
expect(File.read("test.err"))
|
1114
|
+
.to include "Document must include (references) Normative References"
|
1092
1115
|
|
1093
1116
|
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
1094
1117
|
= Document title
|
@@ -1117,7 +1140,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1117
1140
|
== Appendix C
|
1118
1141
|
|
1119
1142
|
INPUT
|
1120
|
-
expect(File.read("test.err"))
|
1143
|
+
expect(File.read("test.err"))
|
1144
|
+
.not_to include "Document must include (references) Normative References"
|
1121
1145
|
end
|
1122
1146
|
|
1123
1147
|
it "Warning if final section is not named Bibliography" do
|
@@ -1149,7 +1173,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1149
1173
|
== Appendix C
|
1150
1174
|
|
1151
1175
|
INPUT
|
1152
|
-
expect(File.read("test.err"))
|
1176
|
+
expect(File.read("test.err"))
|
1177
|
+
.to include "There are sections after the final Bibliography"
|
1153
1178
|
|
1154
1179
|
Asciidoctor.convert(<<~"INPUT", *OPTIONS)
|
1155
1180
|
= Document title
|
@@ -1184,7 +1209,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1184
1209
|
== Appendix C
|
1185
1210
|
|
1186
1211
|
INPUT
|
1187
|
-
expect(File.read("test.err"))
|
1212
|
+
expect(File.read("test.err"))
|
1213
|
+
.not_to include "There are sections after the final Bibliography"
|
1188
1214
|
end
|
1189
1215
|
|
1190
1216
|
it "Warning if final section is not styled Bibliography" do
|
@@ -1212,7 +1238,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1212
1238
|
== Bibliography
|
1213
1239
|
|
1214
1240
|
INPUT
|
1215
|
-
expect(File.read("test.err"))
|
1241
|
+
expect(File.read("test.err"))
|
1242
|
+
.to include "Section not marked up as [bibliography]"
|
1216
1243
|
end
|
1217
1244
|
|
1218
1245
|
it "Warning if final section is not styled Bibliography false" do
|
@@ -1245,7 +1272,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1245
1272
|
== Bibliography
|
1246
1273
|
|
1247
1274
|
INPUT
|
1248
|
-
expect(File.read("test.err"))
|
1275
|
+
expect(File.read("test.err"))
|
1276
|
+
.not_to include "Section not marked up as [bibliography]"
|
1249
1277
|
end
|
1250
1278
|
|
1251
1279
|
it "Warning if English title intro and no French title intro" do
|
@@ -1536,7 +1564,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1536
1564
|
[align=mid-air]
|
1537
1565
|
Para
|
1538
1566
|
INPUT
|
1539
|
-
expect(File.read("test.err"))
|
1567
|
+
expect(File.read("test.err"))
|
1568
|
+
.to include 'value of attribute "align" is invalid; must be equal to'
|
1540
1569
|
end
|
1541
1570
|
|
1542
1571
|
it "Warn if more than 7 levels of subclause" do
|
@@ -1568,7 +1597,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1568
1597
|
====== Clause
|
1569
1598
|
|
1570
1599
|
INPUT
|
1571
|
-
expect(File.read("test.err"))
|
1600
|
+
expect(File.read("test.err"))
|
1601
|
+
.to include "Exceeds the maximum clause depth of 7"
|
1572
1602
|
end
|
1573
1603
|
|
1574
1604
|
it "Do not warn if not more than 7 levels of subclause" do
|
@@ -1597,7 +1627,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1597
1627
|
====== Clause
|
1598
1628
|
|
1599
1629
|
INPUT
|
1600
|
-
expect(File.read("test.err"))
|
1630
|
+
expect(File.read("test.err"))
|
1631
|
+
.not_to include "exceeds the maximum clause depth of 7"
|
1601
1632
|
end
|
1602
1633
|
|
1603
1634
|
it "Warn if term citation in Terms & Definitions not preceded with italicised term" do
|
@@ -1609,8 +1640,9 @@ RSpec.describe Asciidoctor::ISO do
|
|
1609
1640
|
=== Term
|
1610
1641
|
|
1611
1642
|
The definition of a term (<<term>>) is a part of the specialized vocabulary of a particular field
|
1612
|
-
|
1613
|
-
|
1643
|
+
INPUT
|
1644
|
+
expect(File.read("test.err"))
|
1645
|
+
.to include "term citation not preceded with italicised term"
|
1614
1646
|
end
|
1615
1647
|
|
1616
1648
|
it "Warn if an undated reference has no associated footnote" do
|
@@ -1621,7 +1653,8 @@ RSpec.describe Asciidoctor::ISO do
|
|
1621
1653
|
== Bibliography
|
1622
1654
|
* [[[ISO8,ISO 8:--]]], _Title_
|
1623
1655
|
INPUT
|
1624
|
-
expect(File.read("test.err"))
|
1625
|
-
"Reference ISO8 does not have an associated footnote
|
1656
|
+
expect(File.read("test.err"))
|
1657
|
+
.to include "Reference ISO8 does not have an associated footnote "\
|
1658
|
+
"indicating unpublished status"
|
1626
1659
|
end
|
1627
1660
|
end
|
@@ -25,80 +25,86 @@ WORD_HTML_CSS_WORDINTRO = {
|
|
25
25
|
|
26
26
|
RSpec.describe IsoDoc do
|
27
27
|
it "generates file based on string input" do
|
28
|
-
IsoDoc::Iso::HtmlConvert
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<title
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
IsoDoc::Iso::HtmlConvert
|
29
|
+
.new(WORD_HTML_CSS.merge(filename: "test"))
|
30
|
+
.convert("test", <<~"INPUT", false)
|
31
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
32
|
+
<bibdata>
|
33
|
+
<title>
|
34
|
+
<title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
|
35
|
+
<title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
|
36
|
+
<title format="text/plain" language="en" type="title-part">Rice</title>
|
37
|
+
</title>
|
38
|
+
</bibdata>
|
39
|
+
<preface>
|
40
|
+
<foreword>
|
41
|
+
<note>
|
42
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
43
|
+
</note>
|
44
|
+
</foreword>
|
45
|
+
</preface>
|
46
|
+
</iso-standard>
|
45
47
|
INPUT
|
46
48
|
expect(File.exist?("test.html")).to be true
|
47
49
|
html = File.read("test.html", encoding: "UTF-8")
|
48
|
-
expect(html).to
|
49
|
-
|
50
|
-
)
|
50
|
+
expect(html).to include "<title>Cereals and pulses — "\
|
51
|
+
"Specifications and test methods — Rice</title>"
|
51
52
|
expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
|
52
53
|
expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
|
53
54
|
end
|
54
55
|
|
55
56
|
it "generates HTML output docs with null configuration" do
|
56
|
-
IsoDoc::Iso::HtmlConvert
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
<title
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
57
|
+
IsoDoc::Iso::HtmlConvert
|
58
|
+
.new(WORD_HTML_CSS.dup)
|
59
|
+
.convert("test", <<~"INPUT", false)
|
60
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
61
|
+
<bibdata>
|
62
|
+
<title>
|
63
|
+
<title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
|
64
|
+
<title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
|
65
|
+
<title format="text/plain" language="en" type="title-part">Rice</title>
|
66
|
+
</title>
|
67
|
+
</bibdata>
|
68
|
+
<preface>
|
69
|
+
<foreword>
|
70
|
+
<note>
|
71
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
72
|
+
</note>
|
73
|
+
</foreword>
|
74
|
+
</preface>
|
75
|
+
</iso-standard>
|
76
|
+
INPUT
|
74
77
|
expect(File.exist?("test.html")).to be true
|
75
78
|
html = File.read("test.html", encoding: "UTF-8")
|
76
|
-
expect(html).to
|
77
|
-
|
78
|
-
)
|
79
|
+
expect(html).to include "title>Cereals and pulses — "\
|
80
|
+
"Specifications and test methods — Rice</title>"
|
79
81
|
expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
|
80
82
|
expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
|
81
83
|
end
|
82
84
|
|
83
85
|
it "generates Word output docs with null configuration" do
|
84
|
-
IsoDoc::Iso::WordConvert
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
86
|
+
IsoDoc::Iso::WordConvert
|
87
|
+
.new(WORD_HTML_CSS.dup)
|
88
|
+
.convert("test", <<~"INPUT", false)
|
89
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
90
|
+
<preface>
|
91
|
+
<foreword>
|
92
|
+
<note>
|
93
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
94
|
+
</note>
|
95
|
+
</foreword>
|
96
|
+
</preface>
|
97
|
+
</iso-standard>
|
98
|
+
INPUT
|
95
99
|
expect(File.exist?("test.doc")).to be true
|
96
100
|
word = File.read("test.doc", encoding: "UTF-8")
|
97
101
|
expect(word).to match(/<style>/)
|
98
102
|
end
|
99
103
|
|
100
104
|
it "generates HTML output docs with null configuration from file" do
|
101
|
-
IsoDoc::Iso::HtmlConvert
|
105
|
+
IsoDoc::Iso::HtmlConvert
|
106
|
+
.new(WORD_HTML_CSS_SUBDIR.dup)
|
107
|
+
.convert("spec/assets/iso.xml", nil, false)
|
102
108
|
expect(File.exist?("spec/assets/iso.html")).to be true
|
103
109
|
html = File.read("spec/assets/iso.html", encoding: "UTF-8")
|
104
110
|
expect(html).to match(/<style>/)
|
@@ -107,7 +113,9 @@ RSpec.describe IsoDoc do
|
|
107
113
|
end
|
108
114
|
|
109
115
|
it "generates Word output docs with null configuration from file" do
|
110
|
-
IsoDoc::Iso::WordConvert
|
116
|
+
IsoDoc::Iso::WordConvert
|
117
|
+
.new(WORD_HTML_CSS_SUBDIR.dup)
|
118
|
+
.convert("spec/assets/iso.xml", nil, false)
|
111
119
|
expect(File.exist?("spec/assets/iso.doc")).to be true
|
112
120
|
word = File.read("spec/assets/iso.doc", encoding: "UTF-8")
|
113
121
|
expect(word).to match(/<w:WordDocument>/)
|
@@ -116,28 +124,32 @@ RSpec.describe IsoDoc do
|
|
116
124
|
|
117
125
|
it "generates Pdf output docs with null configuration from file" do
|
118
126
|
mock_pdf
|
119
|
-
IsoDoc::Iso::PdfConvert
|
127
|
+
IsoDoc::Iso::PdfConvert
|
128
|
+
.new(WORD_HTML_CSS.dup)
|
129
|
+
.convert("spec/assets/iso.xml", nil, false)
|
120
130
|
expect(File.exist?("spec/assets/iso.pdf")).to be true
|
121
131
|
end
|
122
132
|
|
123
133
|
it "converts annex subheadings to h2Annex class for Word" do
|
124
|
-
IsoDoc::Iso::WordConvert
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
<
|
129
|
-
<title>
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
134
|
+
IsoDoc::Iso::WordConvert
|
135
|
+
.new(WORD_HTML_CSS.dup)
|
136
|
+
.convert("test", <<~"INPUT", false)
|
137
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
138
|
+
<annex id="P" inline-header="false" obligation="normative">
|
139
|
+
<title>Annex</title>
|
140
|
+
<clause id="Q" inline-header="false" obligation="normative">
|
141
|
+
<title>A.1
|
142
|
+
<tab/>
|
143
|
+
Annex A.1</title>
|
144
|
+
</clause>
|
145
|
+
<appendix id="Q2" inline-header="false" obligation="normative">
|
146
|
+
<title>Appendix 1
|
147
|
+
<tab/>
|
148
|
+
An Appendix</title>
|
149
|
+
</appendix>
|
150
|
+
</annex>
|
151
|
+
</iso-standard>
|
152
|
+
INPUT
|
141
153
|
|
142
154
|
word = File.read("test.doc", encoding: "UTF-8")
|
143
155
|
.sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
|
@@ -170,33 +182,35 @@ RSpec.describe IsoDoc do
|
|
170
182
|
end
|
171
183
|
|
172
184
|
it "populates Word template with terms reference labels" do
|
173
|
-
IsoDoc::Iso::WordConvert
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
<
|
183
|
-
|
184
|
-
<
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
185
|
+
IsoDoc::Iso::WordConvert
|
186
|
+
.new(WORD_HTML_CSS.dup)
|
187
|
+
.convert("test", <<~"INPUT", false)
|
188
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
189
|
+
<sections>
|
190
|
+
<terms id="_terms_and_definitions" obligation="normative">
|
191
|
+
<title>1
|
192
|
+
<tab/>
|
193
|
+
Terms and Definitions</title>
|
194
|
+
<term id="paddy1">
|
195
|
+
<name>1.1</name>
|
196
|
+
<preferred>paddy</preferred>
|
197
|
+
<definition>
|
198
|
+
<p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
|
199
|
+
</definition>
|
200
|
+
<termsource status="modified">
|
201
|
+
<origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
|
202
|
+
<locality type="clause">
|
203
|
+
<referenceFrom>3.1</referenceFrom>
|
204
|
+
</locality>ISO 7301:2011, 3.1</origin>
|
205
|
+
<modification>
|
206
|
+
<p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
|
207
|
+
</modification>
|
208
|
+
</termsource>
|
209
|
+
</term>
|
210
|
+
</terms>
|
211
|
+
</sections>
|
212
|
+
</iso-standard>
|
213
|
+
INPUT
|
200
214
|
|
201
215
|
word = File.read("test.doc", encoding: "UTF-8")
|
202
216
|
.sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
|
@@ -224,139 +238,144 @@ RSpec.describe IsoDoc do
|
|
224
238
|
end
|
225
239
|
|
226
240
|
it "populates Word header" do
|
227
|
-
IsoDoc::Iso::WordConvert
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
241
|
+
IsoDoc::Iso::WordConvert
|
242
|
+
.new(WORD_HTML_CSS_HEADER_HTML.dup)
|
243
|
+
.convert("test", <<~"INPUT", false)
|
244
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
245
|
+
<bibdata type="article">
|
246
|
+
<docidentifier>
|
247
|
+
<project-number part="1">1000</project-number>
|
248
|
+
</docidentifier>
|
249
|
+
</bibdata>
|
250
|
+
</iso-standard>
|
251
|
+
INPUT
|
236
252
|
word = File.read("test.doc", encoding: "UTF-8")
|
237
253
|
expect(word).to include('Content-Disposition: inline; filename="header.html"')
|
238
254
|
end
|
239
255
|
|
240
256
|
it "populates Word ToC" do
|
241
|
-
IsoDoc::Iso::WordConvert
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
<clause id="N" inline-header="false" obligation="normative">
|
249
|
-
<title>1.1
|
250
|
-
<tab/>
|
251
|
-
Introduction
|
252
|
-
<bookmark id="Q"/>
|
253
|
-
to this
|
254
|
-
<fn reference="1">
|
255
|
-
<p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
|
256
|
-
</title>
|
257
|
-
</clause>
|
258
|
-
<clause id="O" inline-header="false" obligation="normative">
|
259
|
-
<title>1.2
|
257
|
+
IsoDoc::Iso::WordConvert
|
258
|
+
.new(WORD_HTML_CSS_WORDINTRO.dup)
|
259
|
+
.convert("test", <<~"INPUT", false)
|
260
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
261
|
+
<sections>
|
262
|
+
<clause id="A" inline-header="false" obligation="normative">
|
263
|
+
<title>1
|
260
264
|
<tab/>
|
261
|
-
Clause 4
|
262
|
-
<
|
263
|
-
<
|
264
|
-
<
|
265
|
-
|
265
|
+
Clause 4</title>
|
266
|
+
<clause id="N" inline-header="false" obligation="normative">
|
267
|
+
<title>1.1
|
268
|
+
<tab/>
|
269
|
+
Introduction
|
270
|
+
<bookmark id="Q"/>
|
271
|
+
to this
|
272
|
+
<fn reference="1">
|
273
|
+
<p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
|
274
|
+
</title>
|
275
|
+
</clause>
|
276
|
+
<clause id="O" inline-header="false" obligation="normative">
|
277
|
+
<title>1.2
|
278
|
+
<tab/>
|
279
|
+
Clause 4.2</title>
|
280
|
+
<p>A
|
281
|
+
<fn reference="1">
|
282
|
+
<p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
|
283
|
+
</p>
|
284
|
+
</clause>
|
266
285
|
</clause>
|
267
|
-
</
|
268
|
-
</
|
269
|
-
|
270
|
-
INPUT
|
286
|
+
</sections>
|
287
|
+
</iso-standard>
|
288
|
+
INPUT
|
271
289
|
|
272
290
|
word = File.read("test.doc", encoding: "UTF-8")
|
273
291
|
.sub(/^.*An empty word intro page\./m, "")
|
274
292
|
.sub(%r{</div>.*$}m, "</div>")
|
275
293
|
|
276
|
-
expect(xmlpp("<div>#{word.gsub(/_Toc\d\d+/, '_Toc')}"))
|
277
|
-
|
278
|
-
<
|
279
|
-
<
|
280
|
-
<span
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
<span
|
286
|
-
<
|
287
|
-
<
|
288
|
-
<span
|
289
|
-
|
290
|
-
<span
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
<span
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
<span
|
300
|
-
|
301
|
-
|
294
|
+
expect(xmlpp("<div>#{word.gsub(/_Toc\d\d+/, '_Toc')}"))
|
295
|
+
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
296
|
+
<div>
|
297
|
+
<p class="MsoToc1">
|
298
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
299
|
+
<span style="mso-element:field-begin"/>
|
300
|
+
<span style="mso-spacerun:yes"> </span>TOC
|
301
|
+
\o "1-3" \h \z \u
|
302
|
+
<span style="mso-element:field-separator"/></span>
|
303
|
+
<span class="MsoHyperlink">
|
304
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
305
|
+
<a href="#_Toc">1 Clause 4
|
306
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
307
|
+
<span style="mso-tab-count:1 dotted">. </span></span>
|
308
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
309
|
+
<span style="mso-element:field-begin"/>
|
310
|
+
</span>
|
311
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
|
312
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
313
|
+
<span style="mso-element:field-separator"/>
|
314
|
+
</span>
|
315
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
|
316
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
|
317
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
318
|
+
<span style="mso-element:field-end"/>
|
319
|
+
</span>
|
320
|
+
</a>
|
321
|
+
</span>
|
302
322
|
</span>
|
303
|
-
</
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
<span
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
</
|
323
|
-
</
|
323
|
+
</p>
|
324
|
+
<p class="MsoToc2">
|
325
|
+
<span class="MsoHyperlink">
|
326
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
327
|
+
<a href="#_Toc">1.1 Introduction to this
|
328
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
329
|
+
<span style="mso-tab-count:1 dotted">. </span></span>
|
330
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
331
|
+
<span style="mso-element:field-begin"/>
|
332
|
+
</span>
|
333
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
|
334
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
335
|
+
<span style="mso-element:field-separator"/>
|
336
|
+
</span>
|
337
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
|
338
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
|
339
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
340
|
+
<span style="mso-element:field-end"/>
|
341
|
+
</span>
|
342
|
+
</a>
|
343
|
+
</span>
|
324
344
|
</span>
|
325
|
-
</
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
<span
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
</
|
345
|
-
</
|
345
|
+
</p>
|
346
|
+
<p class="MsoToc2">
|
347
|
+
<span class="MsoHyperlink">
|
348
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
349
|
+
<a href="#_Toc">1.2 Clause 4.2
|
350
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
351
|
+
<span style="mso-tab-count:1 dotted">. </span></span>
|
352
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
353
|
+
<span style="mso-element:field-begin"/>
|
354
|
+
</span>
|
355
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
|
356
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
357
|
+
<span style="mso-element:field-separator"/>
|
358
|
+
</span>
|
359
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
|
360
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
|
361
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
362
|
+
<span style="mso-element:field-end"/>
|
363
|
+
</span>
|
364
|
+
</a>
|
365
|
+
</span>
|
346
366
|
</span>
|
347
|
-
</
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
</
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
OUTPUT
|
367
|
+
</p>
|
368
|
+
<p class="MsoToc1">
|
369
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
370
|
+
<span style="mso-element:field-end"/>
|
371
|
+
</span>
|
372
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
373
|
+
<p class="MsoNormal"> </p>
|
374
|
+
</span>
|
375
|
+
</p>
|
376
|
+
<p class="MsoNormal"> </p>
|
377
|
+
</div>
|
378
|
+
OUTPUT
|
360
379
|
end
|
361
380
|
|
362
381
|
it "reorders footnote numbers" do
|
@@ -390,10 +409,13 @@ RSpec.describe IsoDoc do
|
|
390
409
|
</iso-standard>
|
391
410
|
INPUT
|
392
411
|
|
393
|
-
IsoDoc::Iso::HtmlConvert
|
412
|
+
IsoDoc::Iso::HtmlConvert
|
413
|
+
.new(WORD_HTML_CSS_WORDINTRO.dup)
|
414
|
+
.convert("test", input, false)
|
394
415
|
|
395
416
|
html = File.read("test.html", encoding: "UTF-8")
|
396
|
-
.sub(/^.*<main class="main-section">/m,
|
417
|
+
.sub(/^.*<main class="main-section">/m,
|
418
|
+
'<main xmlns:epub="epub" class="main-section">')
|
397
419
|
.sub(%r{</main>.*$}m, "</main>")
|
398
420
|
|
399
421
|
expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
@@ -436,11 +458,15 @@ RSpec.describe IsoDoc do
|
|
436
458
|
</main>
|
437
459
|
OUTPUT
|
438
460
|
|
439
|
-
IsoDoc::Iso::WordConvert
|
461
|
+
IsoDoc::Iso::WordConvert
|
462
|
+
.new(WORD_HTML_CSS_WORDINTRO.dup)
|
463
|
+
.convert("test", input, false)
|
440
464
|
|
441
465
|
html = File.read("test.doc", encoding: "UTF-8")
|
442
|
-
.sub(/^.*<div class="WordSection3"/m,
|
443
|
-
|
466
|
+
.sub(/^.*<div class="WordSection3"/m,
|
467
|
+
'<body xmlns:epub="epub"><div class="WordSection3"')
|
468
|
+
.sub(%r{</body>.*$}m, "</body>")
|
469
|
+
.gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")
|
444
470
|
|
445
471
|
expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
446
472
|
<body xmlns:epub="epub">
|
@@ -529,75 +555,77 @@ RSpec.describe IsoDoc do
|
|
529
555
|
end
|
530
556
|
|
531
557
|
it "processes IsoXML terms for HTML" do
|
532
|
-
IsoDoc::Iso::HtmlConvert
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
<
|
538
|
-
<
|
539
|
-
<
|
540
|
-
|
541
|
-
|
542
|
-
<
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
<
|
547
|
-
<
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
<
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
<
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
558
|
+
IsoDoc::Iso::HtmlConvert
|
559
|
+
.new(WORD_HTML_CSS.dup)
|
560
|
+
.convert("test", <<~"INPUT", false)
|
561
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
562
|
+
<sections>
|
563
|
+
<terms id="_terms_and_definitions" obligation="normative">
|
564
|
+
<title>Terms and Definitions</title>
|
565
|
+
<term id="paddy1">
|
566
|
+
<name>1.1</name>
|
567
|
+
<preferred>paddy</preferred>
|
568
|
+
<domain>rice</domain>
|
569
|
+
<definition>
|
570
|
+
<p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
|
571
|
+
</definition>
|
572
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
|
573
|
+
<p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
|
574
|
+
<ul>
|
575
|
+
<li>A</li>
|
576
|
+
</ul>
|
577
|
+
</termexample>
|
578
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
|
579
|
+
<ul>
|
580
|
+
<li>A</li>
|
581
|
+
</ul>
|
582
|
+
</termexample>
|
583
|
+
<termsource status="modified">
|
584
|
+
<origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
|
585
|
+
<locality type="clause">
|
586
|
+
<referenceFrom>3.1</referenceFrom>
|
587
|
+
</locality>
|
588
|
+
</origin>
|
589
|
+
<modification>
|
590
|
+
<p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
|
591
|
+
</modification>
|
592
|
+
</termsource>
|
593
|
+
</term>
|
594
|
+
<term id="paddy">
|
595
|
+
<name>1.2</name>
|
596
|
+
<preferred>paddy</preferred>
|
597
|
+
<admitted>paddy rice</admitted>
|
598
|
+
<admitted>rough rice</admitted>
|
599
|
+
<deprecates>cargo rice</deprecates>
|
600
|
+
<definition>
|
601
|
+
<p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
|
602
|
+
</definition>
|
603
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
|
604
|
+
<ul>
|
605
|
+
<li>A</li>
|
606
|
+
</ul>
|
607
|
+
</termexample>
|
608
|
+
<termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
|
609
|
+
<p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
|
610
|
+
</termnote>
|
611
|
+
<termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
|
612
|
+
<ul>
|
613
|
+
<li>A</li>
|
614
|
+
</ul>
|
615
|
+
<p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
|
616
|
+
</termnote>
|
617
|
+
<termsource status="identical">
|
618
|
+
<origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
|
619
|
+
<locality type="clause">
|
620
|
+
<referenceFrom>3.1</referenceFrom>
|
621
|
+
</locality>
|
622
|
+
</origin>
|
623
|
+
</termsource>
|
624
|
+
</term>
|
625
|
+
</terms>
|
626
|
+
</sections>
|
627
|
+
</iso-standard>
|
628
|
+
INPUT
|
601
629
|
expect(File.exist?("test.html")).to be true
|
602
630
|
html = File.read("test.html", encoding: "UTF-8")
|
603
631
|
expect(html).to match(%r{<h2 class="TermNum" id="paddy1">1\.1</h2>})
|
@@ -605,18 +633,20 @@ RSpec.describe IsoDoc do
|
|
605
633
|
end
|
606
634
|
|
607
635
|
it "inserts default paragraph between two tables for Word" do
|
608
|
-
IsoDoc::Iso::WordConvert
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
636
|
+
IsoDoc::Iso::WordConvert
|
637
|
+
.new(WORD_HTML_CSS.dup)
|
638
|
+
.convert("test", <<~"INPUT", false)
|
639
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
640
|
+
<annex id="P" inline-header="false" obligation="normative">
|
641
|
+
<example id="_63112cbc-cde0-435f-9553-e0b8c4f5851c">
|
642
|
+
<p id="_158d4efa-b1c9-4aec-b325-756de8e4c968">'1M', '01M', and '0001M' all describe the calendar month January.</p>
|
643
|
+
</example>
|
644
|
+
<example id="_63112cbc-cde0-435f-9553-e0b8c4f5851d">
|
645
|
+
<p id="_158d4efa-b1c9-4aec-b325-756de8e4c969">'2M', '02M', and '0002M' all describe the calendar month February.</p>
|
646
|
+
</example>
|
647
|
+
</annex>
|
648
|
+
</iso-standard>
|
649
|
+
INPUT
|
620
650
|
word = File.read("test.doc", encoding: "UTF-8")
|
621
651
|
.sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
|
622
652
|
.sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
|
@@ -644,24 +674,26 @@ RSpec.describe IsoDoc do
|
|
644
674
|
end
|
645
675
|
|
646
676
|
it "processes figure keys (Word)" do
|
647
|
-
IsoDoc::Iso::WordConvert
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
<
|
653
|
-
|
654
|
-
<
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
677
|
+
IsoDoc::Iso::WordConvert
|
678
|
+
.new(WORD_HTML_CSS.dup)
|
679
|
+
.convert("test", <<~"INPUT", false)
|
680
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
681
|
+
<annex id="P" inline-header="false" obligation="normative">
|
682
|
+
<figure id="samplecode">
|
683
|
+
<p>Hello</p>
|
684
|
+
<p>Key</p>
|
685
|
+
<dl>
|
686
|
+
<dt>
|
687
|
+
<p>A</p>
|
688
|
+
</dt>
|
689
|
+
<dd>
|
690
|
+
<p>B</p>
|
691
|
+
</dd>
|
692
|
+
</dl>
|
693
|
+
</figure>
|
694
|
+
</annex>
|
695
|
+
</iso-standard>
|
696
|
+
INPUT
|
665
697
|
word = File.read("test.doc", encoding: "UTF-8")
|
666
698
|
.sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
|
667
699
|
.sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
|
@@ -797,17 +829,22 @@ RSpec.describe IsoDoc do
|
|
797
829
|
.sub(%r{<localized-strings>.*</localized-strings>}m, ""))
|
798
830
|
.to be_equivalent_to xmlpp(presxml)
|
799
831
|
|
800
|
-
IsoDoc::Iso::HtmlConvert
|
832
|
+
IsoDoc::Iso::HtmlConvert
|
833
|
+
.new(WORD_HTML_CSS.dup)
|
834
|
+
.convert("test", presxml, false)
|
801
835
|
|
802
836
|
word = File.read("test.html", encoding: "UTF-8")
|
803
837
|
expect((word)).to include '<h1 class="IntroTitle">Warning for Stuff</h1>'
|
804
838
|
expect((word)).to include "I am the Walrus."
|
805
839
|
|
806
|
-
IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup)
|
840
|
+
IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup)
|
841
|
+
.convert("test", presxml, false)
|
807
842
|
word = File.read("test.doc", encoding: "UTF-8")
|
808
843
|
expect(xmlpp(word
|
809
|
-
.sub(%r{^.*<div class="boilerplate-copyright">}m,
|
810
|
-
|
844
|
+
.sub(%r{^.*<div class="boilerplate-copyright">}m,
|
845
|
+
'<div class="boilerplate-copyright">')
|
846
|
+
.sub(%r{</div>.*$}m, "</div></div>")))
|
847
|
+
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
811
848
|
<div class="boilerplate-copyright">
|
812
849
|
<div>
|
813
850
|
<p class="zzCopyright">
|
@@ -839,125 +876,129 @@ RSpec.describe IsoDoc do
|
|
839
876
|
</div>
|
840
877
|
</div>
|
841
878
|
OUTPUT
|
842
|
-
expect(word).to include '<p class="zzWarning">This document is not
|
879
|
+
expect(word).to include '<p class="zzWarning">This document is not '\
|
880
|
+
"an ISO International Standard"
|
843
881
|
end
|
844
882
|
|
845
883
|
it "populates Word ToC" do
|
846
|
-
IsoDoc::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup)
|
847
|
-
|
848
|
-
<
|
849
|
-
<
|
850
|
-
<
|
851
|
-
|
852
|
-
<
|
853
|
-
<
|
854
|
-
|
855
|
-
|
856
|
-
<
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
<
|
861
|
-
|
862
|
-
<
|
863
|
-
<
|
864
|
-
|
865
|
-
|
866
|
-
<
|
884
|
+
IsoDoc::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup)
|
885
|
+
.convert("test", <<~"INPUT", false)
|
886
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
887
|
+
<sections>
|
888
|
+
<clause id="A" inline-header="false" obligation="normative">
|
889
|
+
<title>Clause 4</title>
|
890
|
+
<clause id="N" inline-header="false" obligation="normative">
|
891
|
+
<title>Introduction
|
892
|
+
<bookmark id="Q"/>
|
893
|
+
to this
|
894
|
+
<fn reference="1">
|
895
|
+
<p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
|
896
|
+
</title>
|
897
|
+
</clause>
|
898
|
+
<clause id="O" inline-header="false" obligation="normative">
|
899
|
+
<title>Clause 4.2</title>
|
900
|
+
<p>A
|
901
|
+
<fn reference="1">
|
902
|
+
<p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
|
903
|
+
</p>
|
904
|
+
<clause id="P" inline-header="false" obligation="normative">
|
905
|
+
<title>Clause 4.2.1</title>
|
906
|
+
</clause>
|
867
907
|
</clause>
|
868
908
|
</clause>
|
869
|
-
</
|
870
|
-
</
|
871
|
-
|
872
|
-
INPUT
|
909
|
+
</sections>
|
910
|
+
</iso-standard>
|
911
|
+
INPUT
|
873
912
|
word = File.read("test.doc")
|
874
|
-
.sub(/^.*<div class="WordSection2">/m,
|
913
|
+
.sub(/^.*<div class="WordSection2">/m,
|
914
|
+
'<div class="WordSection2">')
|
875
915
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
876
916
|
|
877
|
-
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")))
|
878
|
-
|
879
|
-
<
|
880
|
-
<
|
881
|
-
<span
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
<span
|
888
|
-
<
|
889
|
-
<
|
890
|
-
<span
|
891
|
-
|
892
|
-
<span
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
<span
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
<span
|
902
|
-
|
903
|
-
|
917
|
+
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")))
|
918
|
+
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
919
|
+
<div class="WordSection2">An empty word intro page.
|
920
|
+
<p class="MsoToc1">
|
921
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
922
|
+
<span style="mso-element:field-begin"/>
|
923
|
+
<span style="mso-spacerun:yes"> </span>
|
924
|
+
TOC
|
925
|
+
\o "1-2" \h \z \u
|
926
|
+
<span style="mso-element:field-separator"/></span>
|
927
|
+
<span class="MsoHyperlink">
|
928
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
929
|
+
<a href="#_Toc">Clause 4
|
930
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
931
|
+
<span style="mso-tab-count:1 dotted">. </span></span>
|
932
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
933
|
+
<span style="mso-element:field-begin"/>
|
934
|
+
</span>
|
935
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
|
936
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
937
|
+
<span style="mso-element:field-separator"/>
|
938
|
+
</span>
|
939
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
|
940
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
|
941
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
942
|
+
<span style="mso-element:field-end"/>
|
943
|
+
</span>
|
944
|
+
</a>
|
945
|
+
</span>
|
904
946
|
</span>
|
905
|
-
</
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
<span
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
</
|
925
|
-
</
|
947
|
+
</p>
|
948
|
+
<p class="MsoToc2">
|
949
|
+
<span class="MsoHyperlink">
|
950
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
951
|
+
<a href="#_Toc">Introduction to this
|
952
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
953
|
+
<span style="mso-tab-count:1 dotted">. </span></span>
|
954
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
955
|
+
<span style="mso-element:field-begin"/>
|
956
|
+
</span>
|
957
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
|
958
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
959
|
+
<span style="mso-element:field-separator"/>
|
960
|
+
</span>
|
961
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
|
962
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
|
963
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
964
|
+
<span style="mso-element:field-end"/>
|
965
|
+
</span>
|
966
|
+
</a>
|
967
|
+
</span>
|
926
968
|
</span>
|
927
|
-
</
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
<span
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
</
|
947
|
-
</
|
969
|
+
</p>
|
970
|
+
<p class="MsoToc2">
|
971
|
+
<span class="MsoHyperlink">
|
972
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
973
|
+
<a href="#_Toc">Clause 4.2
|
974
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
975
|
+
<span style="mso-tab-count:1 dotted">. </span></span>
|
976
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
977
|
+
<span style="mso-element:field-begin"/>
|
978
|
+
</span>
|
979
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
|
980
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
981
|
+
<span style="mso-element:field-separator"/>
|
982
|
+
</span>
|
983
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
|
984
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
|
985
|
+
<span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
|
986
|
+
<span style="mso-element:field-end"/>
|
987
|
+
</span>
|
988
|
+
</a>
|
989
|
+
</span>
|
948
990
|
</span>
|
949
|
-
</
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
</
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
OUTPUT
|
991
|
+
</p>
|
992
|
+
<p class="MsoToc1">
|
993
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
994
|
+
<span style="mso-element:field-end"/>
|
995
|
+
</span>
|
996
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
997
|
+
<p class="MsoNormal"> </p>
|
998
|
+
</span>
|
999
|
+
</p>
|
1000
|
+
<p class="MsoNormal"> </p>
|
1001
|
+
</div>
|
1002
|
+
OUTPUT
|
962
1003
|
end
|
963
1004
|
end
|