metanorma-iso 1.7.1 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +11 -41
- data/.gitignore +2 -0
- data/.rubocop.yml +6 -2
- data/lib/asciidoctor/iso/base.rb +18 -16
- data/lib/asciidoctor/iso/biblio.rng +4 -6
- data/lib/asciidoctor/iso/cleanup.rb +28 -24
- data/lib/asciidoctor/iso/front.rb +26 -16
- data/lib/asciidoctor/iso/front_id.rb +30 -25
- data/lib/asciidoctor/iso/isodoc.rng +172 -3
- data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
- data/lib/asciidoctor/iso/isostandard.rng +17 -97
- data/lib/asciidoctor/iso/validate.rb +22 -109
- data/lib/asciidoctor/iso/validate_image.rb +97 -0
- data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
- data/lib/asciidoctor/iso/validate_section.rb +39 -20
- data/lib/asciidoctor/iso/validate_style.rb +36 -24
- data/lib/asciidoctor/iso/validate_title.rb +23 -17
- data/lib/isodoc/iso/base_convert.rb +19 -2
- data/lib/isodoc/iso/html/style-human.css +7 -0
- data/lib/isodoc/iso/html/style-iso.css +7 -0
- data/lib/isodoc/iso/html_convert.rb +0 -1
- data/lib/isodoc/iso/i18n-en.yaml +4 -0
- data/lib/isodoc/iso/i18n-fr.yaml +4 -0
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +4 -0
- data/lib/isodoc/iso/index.rb +140 -0
- data/lib/isodoc/iso/iso.amendment.xsl +1092 -208
- data/lib/isodoc/iso/iso.international-standard.xsl +1092 -208
- data/lib/isodoc/iso/presentation_xml_convert.rb +45 -37
- data/lib/isodoc/iso/word_convert.rb +0 -1
- data/lib/isodoc/iso/xref.rb +15 -7
- data/lib/metanorma/iso/processor.rb +1 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +8 -8
- data/spec/asciidoctor/amd_spec.rb +696 -0
- data/spec/asciidoctor/base_spec.rb +733 -0
- data/spec/asciidoctor/blocks_spec.rb +527 -0
- data/spec/asciidoctor/cleanup_spec.rb +1134 -0
- data/spec/asciidoctor/inline_spec.rb +195 -0
- data/spec/asciidoctor/lists_spec.rb +197 -0
- data/spec/asciidoctor/refs_spec.rb +375 -0
- data/spec/asciidoctor/section_spec.rb +393 -0
- data/spec/asciidoctor/table_spec.rb +329 -0
- data/spec/asciidoctor/validate_spec.rb +1627 -0
- data/spec/isodoc/amd_spec.rb +967 -946
- data/spec/isodoc/blocks_spec.rb +530 -507
- data/spec/isodoc/i18n_spec.rb +953 -911
- data/spec/isodoc/inline_spec.rb +355 -293
- data/spec/isodoc/iso_spec.rb +338 -314
- data/spec/isodoc/metadata_spec.rb +392 -382
- data/spec/isodoc/postproc_spec.rb +836 -657
- data/spec/isodoc/ref_spec.rb +374 -331
- data/spec/isodoc/section_spec.rb +821 -519
- data/spec/isodoc/table_spec.rb +472 -411
- data/spec/isodoc/terms_spec.rb +209 -185
- data/spec/isodoc/xref_spec.rb +1370 -1236
- data/spec/metanorma/processor_spec.rb +28 -26
- data/spec/spec_helper.rb +178 -193
- metadata +65 -66
- data/.rubocop.ribose.yml +0 -66
- data/lib/isodoc/iso/html/scripts.html +0 -178
- data/spec/asciidoctor-iso/amd_spec.rb +0 -694
- data/spec/asciidoctor-iso/base_spec.rb +0 -713
- data/spec/asciidoctor-iso/blocks_spec.rb +0 -482
- data/spec/asciidoctor-iso/cleanup_spec.rb +0 -1025
- data/spec/asciidoctor-iso/inline_spec.rb +0 -170
- data/spec/asciidoctor-iso/lists_spec.rb +0 -190
- data/spec/asciidoctor-iso/refs_spec.rb +0 -317
- data/spec/asciidoctor-iso/section_spec.rb +0 -362
- data/spec/asciidoctor-iso/table_spec.rb +0 -313
- data/spec/asciidoctor-iso/validate_spec.rb +0 -1621
- data/spec/assets/xref_error.adoc +0 -7
@@ -86,6 +86,35 @@
|
|
86
86
|
<text/>
|
87
87
|
</element>
|
88
88
|
</define>
|
89
|
+
<define name="erefType">
|
90
|
+
<optional>
|
91
|
+
<attribute name="normative">
|
92
|
+
<data type="boolean"/>
|
93
|
+
</attribute>
|
94
|
+
</optional>
|
95
|
+
<attribute name="citeas"/>
|
96
|
+
<attribute name="type">
|
97
|
+
<ref name="ReferenceFormat"/>
|
98
|
+
</attribute>
|
99
|
+
<optional>
|
100
|
+
<attribute name="alt"/>
|
101
|
+
</optional>
|
102
|
+
<optional>
|
103
|
+
<attribute name="case">
|
104
|
+
<choice>
|
105
|
+
<value>capital</value>
|
106
|
+
<value>lowercase</value>
|
107
|
+
</choice>
|
108
|
+
</attribute>
|
109
|
+
</optional>
|
110
|
+
<optional>
|
111
|
+
<attribute name="droploc">
|
112
|
+
<data type="boolean"/>
|
113
|
+
</attribute>
|
114
|
+
</optional>
|
115
|
+
<ref name="CitationType"/>
|
116
|
+
<text/>
|
117
|
+
</define>
|
89
118
|
<define name="ul">
|
90
119
|
<element name="ul">
|
91
120
|
<attribute name="id">
|
@@ -102,7 +131,7 @@
|
|
102
131
|
</attribute>
|
103
132
|
</optional>
|
104
133
|
<oneOrMore>
|
105
|
-
<ref name="
|
134
|
+
<ref name="ul_li"/>
|
106
135
|
</oneOrMore>
|
107
136
|
<zeroOrMore>
|
108
137
|
<ref name="note"/>
|
@@ -775,6 +804,78 @@
|
|
775
804
|
<ref name="paragraph"/>
|
776
805
|
</element>
|
777
806
|
</define>
|
807
|
+
<define name="em">
|
808
|
+
<element name="em">
|
809
|
+
<zeroOrMore>
|
810
|
+
<choice>
|
811
|
+
<ref name="PureTextElement"/>
|
812
|
+
<ref name="stem"/>
|
813
|
+
<ref name="index"/>
|
814
|
+
</choice>
|
815
|
+
</zeroOrMore>
|
816
|
+
</element>
|
817
|
+
</define>
|
818
|
+
<define name="strong">
|
819
|
+
<element name="strong">
|
820
|
+
<zeroOrMore>
|
821
|
+
<choice>
|
822
|
+
<ref name="PureTextElement"/>
|
823
|
+
<ref name="stem"/>
|
824
|
+
<ref name="index"/>
|
825
|
+
</choice>
|
826
|
+
</zeroOrMore>
|
827
|
+
</element>
|
828
|
+
</define>
|
829
|
+
<define name="tt">
|
830
|
+
<element name="tt">
|
831
|
+
<zeroOrMore>
|
832
|
+
<choice>
|
833
|
+
<ref name="PureTextElement"/>
|
834
|
+
<ref name="index"/>
|
835
|
+
</choice>
|
836
|
+
</zeroOrMore>
|
837
|
+
</element>
|
838
|
+
</define>
|
839
|
+
<define name="keyword">
|
840
|
+
<element name="keyword">
|
841
|
+
<zeroOrMore>
|
842
|
+
<choice>
|
843
|
+
<ref name="PureTextElement"/>
|
844
|
+
<ref name="index"/>
|
845
|
+
</choice>
|
846
|
+
</zeroOrMore>
|
847
|
+
</element>
|
848
|
+
</define>
|
849
|
+
<define name="strike">
|
850
|
+
<element name="strike">
|
851
|
+
<zeroOrMore>
|
852
|
+
<choice>
|
853
|
+
<ref name="PureTextElement"/>
|
854
|
+
<ref name="index"/>
|
855
|
+
</choice>
|
856
|
+
</zeroOrMore>
|
857
|
+
</element>
|
858
|
+
</define>
|
859
|
+
<define name="underline">
|
860
|
+
<element name="underline">
|
861
|
+
<zeroOrMore>
|
862
|
+
<choice>
|
863
|
+
<ref name="PureTextElement"/>
|
864
|
+
<ref name="index"/>
|
865
|
+
</choice>
|
866
|
+
</zeroOrMore>
|
867
|
+
</element>
|
868
|
+
</define>
|
869
|
+
<define name="smallcap">
|
870
|
+
<element name="smallcap">
|
871
|
+
<zeroOrMore>
|
872
|
+
<choice>
|
873
|
+
<ref name="PureTextElement"/>
|
874
|
+
<ref name="index"/>
|
875
|
+
</choice>
|
876
|
+
</zeroOrMore>
|
877
|
+
</element>
|
878
|
+
</define>
|
778
879
|
</include>
|
779
880
|
<!-- end overrides -->
|
780
881
|
<define name="colgroup">
|
@@ -793,7 +894,35 @@
|
|
793
894
|
<value>internal</value>
|
794
895
|
</define>
|
795
896
|
<define name="TextElement" combine="choice">
|
796
|
-
<
|
897
|
+
<choice>
|
898
|
+
<ref name="concept"/>
|
899
|
+
<ref name="add"/>
|
900
|
+
<ref name="del"/>
|
901
|
+
</choice>
|
902
|
+
</define>
|
903
|
+
<define name="add">
|
904
|
+
<element name="add">
|
905
|
+
<choice>
|
906
|
+
<ref name="PureTextElement"/>
|
907
|
+
<ref name="eref"/>
|
908
|
+
<ref name="stem"/>
|
909
|
+
<ref name="keyword"/>
|
910
|
+
<ref name="xref"/>
|
911
|
+
<ref name="hyperlink"/>
|
912
|
+
</choice>
|
913
|
+
</element>
|
914
|
+
</define>
|
915
|
+
<define name="del">
|
916
|
+
<element name="del">
|
917
|
+
<choice>
|
918
|
+
<ref name="PureTextElement"/>
|
919
|
+
<ref name="eref"/>
|
920
|
+
<ref name="stem"/>
|
921
|
+
<ref name="keyword"/>
|
922
|
+
<ref name="xref"/>
|
923
|
+
<ref name="hyperlink"/>
|
924
|
+
</choice>
|
925
|
+
</element>
|
797
926
|
</define>
|
798
927
|
<define name="concept">
|
799
928
|
<element name="concept">
|
@@ -919,6 +1048,9 @@
|
|
919
1048
|
</choice>
|
920
1049
|
</attribute>
|
921
1050
|
<ref name="bibdata"/>
|
1051
|
+
<optional>
|
1052
|
+
<ref name="misccontainer"/>
|
1053
|
+
</optional>
|
922
1054
|
<optional>
|
923
1055
|
<ref name="boilerplate"/>
|
924
1056
|
</optional>
|
@@ -929,11 +1061,21 @@
|
|
929
1061
|
<zeroOrMore>
|
930
1062
|
<ref name="annex"/>
|
931
1063
|
</zeroOrMore>
|
1064
|
+
<optional>
|
1065
|
+
<ref name="bibliography"/>
|
1066
|
+
</optional>
|
932
1067
|
<zeroOrMore>
|
933
|
-
<ref name="
|
1068
|
+
<ref name="indexsect"/>
|
934
1069
|
</zeroOrMore>
|
935
1070
|
</element>
|
936
1071
|
</define>
|
1072
|
+
<define name="misccontainer">
|
1073
|
+
<element name="misc-container">
|
1074
|
+
<oneOrMore>
|
1075
|
+
<ref name="AnyElement"/>
|
1076
|
+
</oneOrMore>
|
1077
|
+
</element>
|
1078
|
+
</define>
|
937
1079
|
<define name="preface">
|
938
1080
|
<element name="preface">
|
939
1081
|
<oneOrMore>
|
@@ -957,6 +1099,11 @@
|
|
957
1099
|
<ref name="Content-Section"/>
|
958
1100
|
</element>
|
959
1101
|
</define>
|
1102
|
+
<define name="indexsect">
|
1103
|
+
<element name="indexsect">
|
1104
|
+
<ref name="Content-Section"/>
|
1105
|
+
</element>
|
1106
|
+
</define>
|
960
1107
|
<define name="boilerplate">
|
961
1108
|
<element name="boilerplate">
|
962
1109
|
<optional>
|
@@ -1698,4 +1845,26 @@
|
|
1698
1845
|
</zeroOrMore>
|
1699
1846
|
</element>
|
1700
1847
|
</define>
|
1848
|
+
<define name="ul_li">
|
1849
|
+
<element name="li">
|
1850
|
+
<optional>
|
1851
|
+
<attribute name="id">
|
1852
|
+
<data type="ID"/>
|
1853
|
+
</attribute>
|
1854
|
+
</optional>
|
1855
|
+
<optional>
|
1856
|
+
<attribute name="uncheckedcheckbox">
|
1857
|
+
<data type="boolean"/>
|
1858
|
+
</attribute>
|
1859
|
+
</optional>
|
1860
|
+
<optional>
|
1861
|
+
<attribute name="checkedcheckbox">
|
1862
|
+
<data type="boolean"/>
|
1863
|
+
</attribute>
|
1864
|
+
</optional>
|
1865
|
+
<oneOrMore>
|
1866
|
+
<ref name="BasicBlock"/>
|
1867
|
+
</oneOrMore>
|
1868
|
+
</element>
|
1869
|
+
</define>
|
1701
1870
|
</grammar>
|
@@ -79,19 +79,6 @@
|
|
79
79
|
</choice>
|
80
80
|
</element>
|
81
81
|
</define>
|
82
|
-
<define name="ul">
|
83
|
-
<element name="ul">
|
84
|
-
<attribute name="id">
|
85
|
-
<data type="ID"/>
|
86
|
-
</attribute>
|
87
|
-
<oneOrMore>
|
88
|
-
<ref name="ul_li"/>
|
89
|
-
</oneOrMore>
|
90
|
-
<zeroOrMore>
|
91
|
-
<ref name="note"/>
|
92
|
-
</zeroOrMore>
|
93
|
-
</element>
|
94
|
-
</define>
|
95
82
|
<define name="sections">
|
96
83
|
<element name="sections">
|
97
84
|
<zeroOrMore>
|
@@ -192,17 +179,6 @@
|
|
192
179
|
</zeroOrMore>
|
193
180
|
</element>
|
194
181
|
</define>
|
195
|
-
<define name="definition">
|
196
|
-
<element name="definition">
|
197
|
-
<oneOrMore>
|
198
|
-
<choice>
|
199
|
-
<ref name="paragraph"/>
|
200
|
-
<ref name="figure"/>
|
201
|
-
<ref name="formula"/>
|
202
|
-
</choice>
|
203
|
-
</oneOrMore>
|
204
|
-
</element>
|
205
|
-
</define>
|
206
182
|
<define name="annex">
|
207
183
|
<element name="annex">
|
208
184
|
<optional>
|
@@ -333,6 +309,11 @@
|
|
333
309
|
<optional>
|
334
310
|
<attribute name="script"/>
|
335
311
|
</optional>
|
312
|
+
<optional>
|
313
|
+
<attribute name="inline-header">
|
314
|
+
<data type="boolean"/>
|
315
|
+
</attribute>
|
316
|
+
</optional>
|
336
317
|
<optional>
|
337
318
|
<attribute name="obligation">
|
338
319
|
<choice>
|
@@ -341,6 +322,12 @@
|
|
341
322
|
</choice>
|
342
323
|
</attribute>
|
343
324
|
</optional>
|
325
|
+
<optional>
|
326
|
+
<attribute name="number"/>
|
327
|
+
</optional>
|
328
|
+
<optional>
|
329
|
+
<attribute name="type"/>
|
330
|
+
</optional>
|
344
331
|
<optional>
|
345
332
|
<ref name="section-title"/>
|
346
333
|
</optional>
|
@@ -358,57 +345,6 @@
|
|
358
345
|
</oneOrMore>
|
359
346
|
</choice>
|
360
347
|
</define>
|
361
|
-
<define name="table">
|
362
|
-
<element name="table">
|
363
|
-
<attribute name="id">
|
364
|
-
<data type="ID"/>
|
365
|
-
</attribute>
|
366
|
-
<optional>
|
367
|
-
<attribute name="width"/>
|
368
|
-
</optional>
|
369
|
-
<optional>
|
370
|
-
<attribute name="unnumbered">
|
371
|
-
<data type="boolean"/>
|
372
|
-
</attribute>
|
373
|
-
</optional>
|
374
|
-
<optional>
|
375
|
-
<attribute name="number"/>
|
376
|
-
</optional>
|
377
|
-
<optional>
|
378
|
-
<attribute name="subsequence"/>
|
379
|
-
</optional>
|
380
|
-
<optional>
|
381
|
-
<attribute name="alt"/>
|
382
|
-
</optional>
|
383
|
-
<optional>
|
384
|
-
<attribute name="summary"/>
|
385
|
-
</optional>
|
386
|
-
<optional>
|
387
|
-
<attribute name="uri">
|
388
|
-
<data type="anyURI"/>
|
389
|
-
</attribute>
|
390
|
-
</optional>
|
391
|
-
<optional>
|
392
|
-
<ref name="colgroup"/>
|
393
|
-
</optional>
|
394
|
-
<optional>
|
395
|
-
<ref name="tname"/>
|
396
|
-
</optional>
|
397
|
-
<optional>
|
398
|
-
<ref name="thead"/>
|
399
|
-
</optional>
|
400
|
-
<ref name="tbody"/>
|
401
|
-
<optional>
|
402
|
-
<ref name="tfoot"/>
|
403
|
-
</optional>
|
404
|
-
<zeroOrMore>
|
405
|
-
<ref name="table-note"/>
|
406
|
-
</zeroOrMore>
|
407
|
-
<optional>
|
408
|
-
<ref name="dl"/>
|
409
|
-
</optional>
|
410
|
-
</element>
|
411
|
-
</define>
|
412
348
|
</include>
|
413
349
|
<!-- end overrides -->
|
414
350
|
<!--
|
@@ -428,6 +364,9 @@
|
|
428
364
|
<zeroOrMore>
|
429
365
|
<ref name="termdocsource"/>
|
430
366
|
</zeroOrMore>
|
367
|
+
<optional>
|
368
|
+
<ref name="misccontainer"/>
|
369
|
+
</optional>
|
431
370
|
<optional>
|
432
371
|
<ref name="boilerplate"/>
|
433
372
|
</optional>
|
@@ -439,6 +378,9 @@
|
|
439
378
|
<ref name="annex"/>
|
440
379
|
</zeroOrMore>
|
441
380
|
<ref name="bibliography"/>
|
381
|
+
<zeroOrMore>
|
382
|
+
<ref name="indexsect"/>
|
383
|
+
</zeroOrMore>
|
442
384
|
</element>
|
443
385
|
</define>
|
444
386
|
<define name="horizontal">
|
@@ -527,28 +469,6 @@
|
|
527
469
|
<ref name="Clause-Section"/>
|
528
470
|
</element>
|
529
471
|
</define>
|
530
|
-
<define name="ul_li">
|
531
|
-
<element name="li">
|
532
|
-
<optional>
|
533
|
-
<attribute name="id">
|
534
|
-
<data type="ID"/>
|
535
|
-
</attribute>
|
536
|
-
</optional>
|
537
|
-
<optional>
|
538
|
-
<attribute name="uncheckedcheckbox">
|
539
|
-
<data type="boolean"/>
|
540
|
-
</attribute>
|
541
|
-
</optional>
|
542
|
-
<optional>
|
543
|
-
<attribute name="checkedcheckbox">
|
544
|
-
<data type="boolean"/>
|
545
|
-
</attribute>
|
546
|
-
</optional>
|
547
|
-
<oneOrMore>
|
548
|
-
<ref name="BasicBlock"/>
|
549
|
-
</oneOrMore>
|
550
|
-
</element>
|
551
|
-
</define>
|
552
472
|
<define name="stagename">
|
553
473
|
<element name="stagename">
|
554
474
|
<text/>
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "metanorma-standoc"
|
2
|
-
require_relative "./validate_style
|
3
|
-
require_relative "./validate_requirements
|
4
|
-
require_relative "./validate_section
|
5
|
-
require_relative "./validate_title
|
2
|
+
require_relative "./validate_style"
|
3
|
+
require_relative "./validate_requirements"
|
4
|
+
require_relative "./validate_section"
|
5
|
+
require_relative "./validate_title"
|
6
|
+
require_relative "./validate_image"
|
6
7
|
require "nokogiri"
|
7
8
|
require "jing"
|
8
9
|
require "iev"
|
@@ -10,17 +11,6 @@ require "iev"
|
|
10
11
|
module Asciidoctor
|
11
12
|
module ISO
|
12
13
|
class Converter < Standoc::Converter
|
13
|
-
# ISO/IEC DIR 2, 22.3.2
|
14
|
-
def onlychild_clause_validate(root)
|
15
|
-
root.xpath(Standoc::Utils::SUBCLAUSE_XPATH).each do |c|
|
16
|
-
next unless c.xpath("../clause").size == 1
|
17
|
-
title = c.at("./title")
|
18
|
-
location = c["id"] || c.text[0..60] + "..."
|
19
|
-
location += ":#{title.text}" if c["id"] && !title.nil?
|
20
|
-
@log.add("Style", nil, "#{location}: subclause is only child")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
14
|
def isosubgroup_validate(root)
|
25
15
|
root.xpath("//technical-committee/@type").each do |t|
|
26
16
|
unless %w{TC PC JTC JPC}.include? t.text
|
@@ -37,12 +27,13 @@ module Asciidoctor
|
|
37
27
|
end
|
38
28
|
|
39
29
|
# ISO/IEC DIR 2, 15.5.3
|
30
|
+
# does not deal with preceding text marked up
|
40
31
|
def see_xrefs_validate(root)
|
41
32
|
root.xpath("//xref").each do |t|
|
42
|
-
# does not deal with preceding text marked up
|
43
33
|
preceding = t.at("./preceding-sibling::text()[last()]")
|
44
34
|
next unless !preceding.nil? &&
|
45
35
|
/\b(see| refer to)\s*$/mi.match(preceding)
|
36
|
+
|
46
37
|
(target = root.at("//*[@id = '#{t['target']}']")) || next
|
47
38
|
if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
|
48
39
|
@log.add("Style", t,
|
@@ -54,36 +45,34 @@ module Asciidoctor
|
|
54
45
|
# ISO/IEC DIR 2, 15.5.3
|
55
46
|
def see_erefs_validate(root)
|
56
47
|
root.xpath("//eref").each do |t|
|
57
|
-
|
58
|
-
next unless !
|
59
|
-
|
48
|
+
prec = t.at("./preceding-sibling::text()[last()]")
|
49
|
+
next unless !prec.nil? && /\b(see|refer to)\s*$/mi.match(prec)
|
50
|
+
|
60
51
|
unless target = root.at("//*[@id = '#{t['bibitemid']}']")
|
61
52
|
@log.add("Bibliography", t,
|
62
53
|
"'#{t} is not pointing to a real reference")
|
63
54
|
next
|
64
55
|
end
|
65
|
-
|
56
|
+
target.at("./ancestor::references[@normative = 'true']") and
|
66
57
|
@log.add("Style", t,
|
67
58
|
"'see #{t}' is pointing to a normative reference")
|
68
|
-
end
|
69
59
|
end
|
70
60
|
end
|
71
61
|
|
72
62
|
# ISO/IEC DIR 2, 10.4
|
73
63
|
def locality_erefs_validate(root)
|
74
64
|
root.xpath("//eref[descendant::locality]").each do |t|
|
75
|
-
if /^(ISO|IEC)/.match
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
65
|
+
if /^(ISO|IEC)/.match?(t["citeas"]) &&
|
66
|
+
!(/: ?(\d+{4}|–)$/.match?(t["citeas"]))
|
67
|
+
@log.add("Style", t,
|
68
|
+
"undated reference #{t['citeas']} should not contain "\
|
69
|
+
"specific elements")
|
81
70
|
end
|
82
71
|
end
|
83
72
|
end
|
84
73
|
|
85
|
-
def termdef_warn(text,
|
86
|
-
|
74
|
+
def termdef_warn(text, regex, elem, term, msg)
|
75
|
+
regex.match(text) && @log.add("Style", elem, "#{term}: #{msg}")
|
87
76
|
end
|
88
77
|
|
89
78
|
# ISO/IEC DIR 2, 16.5.6
|
@@ -103,6 +92,7 @@ module Asciidoctor
|
|
103
92
|
def cited_term_style(xmldoc)
|
104
93
|
xmldoc.xpath("//term//xref").each do |x|
|
105
94
|
next unless xmldoc.at("//term[@id = '#{x['target']}']")
|
95
|
+
|
106
96
|
x&.previous&.text == " (" and x&.previous&.previous&.name == "em" or
|
107
97
|
style_warning(x, "term citation not preceded with italicised term",
|
108
98
|
x.parent.text)
|
@@ -111,8 +101,8 @@ module Asciidoctor
|
|
111
101
|
|
112
102
|
def doctype_validate(xmldoc)
|
113
103
|
doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
|
114
|
-
%w(international-standard technical-specification technical-report
|
115
|
-
publicly-available-specification international-workshop-agreement
|
104
|
+
%w(international-standard technical-specification technical-report
|
105
|
+
publicly-available-specification international-workshop-agreement
|
116
106
|
guide amendment technical-corrigendum).include? doctype or
|
117
107
|
@log.add("Document Attributes", nil,
|
118
108
|
"#{doctype} is not a recognised document type")
|
@@ -146,83 +136,6 @@ module Asciidoctor
|
|
146
136
|
"#{iteration} is not a recognised iteration")
|
147
137
|
end
|
148
138
|
|
149
|
-
# DRG directives 3.7; but anticipated by standoc
|
150
|
-
def subfigure_validate(xmldoc)
|
151
|
-
xmldoc.xpath("//figure//figure").each do |f|
|
152
|
-
{ footnote: "fn", note: "note", key: "dl" }.each do |k, v|
|
153
|
-
f.xpath(".//#{v}").each do |n|
|
154
|
-
@log.add("Style", n, "#{k} is not permitted in a subfigure")
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def image_name_prefix(xmldoc)
|
161
|
-
std = xmldoc&.at("//bibdata/ext/structuredidentifier/project-number") or return
|
162
|
-
num = xmldoc&.at("//bibdata/docnumber")&.text or return
|
163
|
-
ed = xmldoc&.at("//bibdata/edition")&.text || "1"
|
164
|
-
prefix = num
|
165
|
-
part = std["part"] and prefix += "-#{std['part']}"
|
166
|
-
prefix += "_ed#{ed}"
|
167
|
-
amd = std["amendment"] and prefix += "amd#{amd}"
|
168
|
-
prefix
|
169
|
-
end
|
170
|
-
|
171
|
-
def image_name_suffix(xmldoc)
|
172
|
-
case xmldoc&.at("//bibdata/language")&.text
|
173
|
-
when "fr" then "_f"
|
174
|
-
when "de" then "_d"
|
175
|
-
when "ru" then "_r"
|
176
|
-
when "es" then "_s"
|
177
|
-
when "ar" then "_a"
|
178
|
-
when "en" then "_e"
|
179
|
-
else
|
180
|
-
"_e"
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def disjunct_error(i, cond1, cond2, msg1, msg2)
|
185
|
-
cond1 && !cond2 and @log.add("Style", i, "image name #{i['src']} #{msg1}")
|
186
|
-
!cond1 && cond2 and @log.add("Style", i, "image name #{i['src']} #{msg2}")
|
187
|
-
end
|
188
|
-
|
189
|
-
def image_name_validate1(i, prefix)
|
190
|
-
m = %r[(SL)?#{prefix}fig(?<tab>Tab)?(?<annex>[A-Z])?(Text)?(?<num>\d+)
|
191
|
-
(?<subfig>[a-z])?(?<key>_key\d+)?(?<lang>_[a-z])?$]x.match(File.basename(i["src"], ".*"))
|
192
|
-
if m.nil?
|
193
|
-
@log.add("Style", i, "image name #{i['src']} does not match DRG requirements")
|
194
|
-
return
|
195
|
-
end
|
196
|
-
warn i['src']
|
197
|
-
disjunct_error(i, i.at("./ancestor::table"), !m[:tab].nil?,
|
198
|
-
"is under a table but is not so labelled", "is labelled as under a table but is not")
|
199
|
-
disjunct_error(i, i.at("./ancestor::annex"), !m[:annex].nil?,
|
200
|
-
"is under an annex but is not so labelled", "is labelled as under an annex but is not")
|
201
|
-
disjunct_error(i, i.xpath("./ancestor::figure").size > 1, !m[:subfig].nil?,
|
202
|
-
"does not have a subfigure letter but is a subfigure",
|
203
|
-
"has a subfigure letter but is not a subfigure")
|
204
|
-
lang = image_name_suffix(i.document.root)
|
205
|
-
(m[:lang] || "_e") == lang or @log.add("Style", i, "image name #{i['src']} expected to have suffix #{lang}")
|
206
|
-
end
|
207
|
-
|
208
|
-
# DRG directives 3.2
|
209
|
-
def image_name_validate(xmldoc)
|
210
|
-
prefix = image_name_prefix(xmldoc) or return
|
211
|
-
xmldoc.xpath("//image").each do |i|
|
212
|
-
if /^ISO_\d+_/.match(File.basename(i["src"]))
|
213
|
-
elsif /^(SL)?#{prefix}fig/.match(File.basename(i["src"]))
|
214
|
-
image_name_validate1(i, prefix)
|
215
|
-
else
|
216
|
-
@log.add("Style", i, "image name #{i['src']} does not match DRG requirements: expect #{prefix}fig")
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def figure_validate(xmldoc)
|
222
|
-
image_name_validate(xmldoc)
|
223
|
-
subfigure_validate(xmldoc)
|
224
|
-
end
|
225
|
-
|
226
139
|
def bibdata_validate(doc)
|
227
140
|
doctype_validate(doc)
|
228
141
|
script_validate(doc)
|
@@ -250,7 +163,7 @@ module Asciidoctor
|
|
250
163
|
xmldoc.xpath("//bibitem[date/on = '–']").each do |b|
|
251
164
|
b.at("./note[@type = 'Unpublished-Status']") or
|
252
165
|
@log.add("Style", b,
|
253
|
-
"Reference #{b&.at(
|
166
|
+
"Reference #{b&.at('./@id')&.text} does not have an "\
|
254
167
|
"associated footnote indicating unpublished status")
|
255
168
|
end
|
256
169
|
end
|