metanorma-iso 1.5.12 → 1.7.0
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 +18 -1
- data/lib/asciidoctor/iso/base.rb +5 -5
- data/lib/asciidoctor/iso/basicdoc.rng +52 -3
- data/lib/asciidoctor/iso/cleanup.rb +0 -6
- data/lib/asciidoctor/iso/front.rb +10 -5
- data/lib/asciidoctor/iso/isodoc.rng +51 -3
- data/lib/asciidoctor/iso/isostandard-amd.rng +8 -4
- data/lib/asciidoctor/iso/isostandard.rng +27 -10
- data/lib/asciidoctor/iso/validate.rb +78 -0
- data/lib/asciidoctor/iso/validate_section.rb +12 -9
- data/lib/isodoc/iso/base_convert.rb +2 -1
- data/lib/isodoc/iso/html/header.html +12 -12
- data/lib/isodoc/iso/html/html_iso_intro.html +1 -1
- data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/htmlstyle.css +1 -1
- data/lib/isodoc/iso/html/htmlstyle.scss +1 -1
- data/lib/isodoc/iso/html/isodoc.css +42 -42
- data/lib/isodoc/iso/html/isodoc.scss +42 -42
- data/lib/isodoc/iso/html/style-human.css +9 -9
- data/lib/isodoc/iso/html/style-human.scss +7 -7
- data/lib/isodoc/iso/html/style-iso.css +7 -7
- data/lib/isodoc/iso/html/style-iso.scss +5 -5
- data/lib/isodoc/iso/html/word_iso_intro.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/wordstyle.css +67 -67
- data/lib/isodoc/iso/html/wordstyle.scss +67 -67
- data/lib/isodoc/iso/html_convert.rb +6 -2
- data/lib/isodoc/iso/i18n-en.yaml +2 -0
- data/lib/isodoc/iso/i18n-fr.yaml +1 -1
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -1
- data/lib/isodoc/iso/iso.amendment.xsl +276 -59
- data/lib/isodoc/iso/iso.international-standard.xsl +276 -59
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/sections.rb +1 -1
- data/lib/isodoc/iso/word_convert.rb +6 -2
- data/lib/isodoc/iso/xref.rb +34 -8
- data/lib/metanorma/iso/processor.rb +11 -9
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +2 -2
- data/spec/asciidoctor-iso/amd_spec.rb +14 -14
- data/spec/asciidoctor-iso/base_spec.rb +22 -20
- data/spec/asciidoctor-iso/blocks_spec.rb +22 -22
- data/spec/asciidoctor-iso/cleanup_spec.rb +32 -26
- data/spec/asciidoctor-iso/inline_spec.rb +7 -7
- data/spec/asciidoctor-iso/lists_spec.rb +9 -9
- data/spec/asciidoctor-iso/refs_spec.rb +5 -5
- data/spec/asciidoctor-iso/section_spec.rb +12 -7
- data/spec/asciidoctor-iso/table_spec.rb +4 -4
- data/spec/asciidoctor-iso/validate_spec.rb +455 -87
- data/spec/isodoc/amd_spec.rb +13 -13
- data/spec/isodoc/iso_spec.rb +2 -2
- data/spec/isodoc/metadata_spec.rb +2 -0
- data/spec/isodoc/section_spec.rb +20 -0
- data/spec/isodoc/xref_spec.rb +12 -0
- metadata +6 -12
- data/.github/workflows/macos.yml +0 -49
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -50
- data/lib/asciidoctor/iso/macros.rb +0 -21
- data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -86
- data/spec/asciidoctor-iso/macros_spec.rb +0 -310
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ec4ec662c484d537eb81f3942a322462babc6f46faa2a4842cb3dd0d933a23a
|
4
|
+
data.tar.gz: 1967914fa124dbe03b21d008f615bb84f576665bf7562d85ef4740bf56d953c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbd9e8c580bc90dc62eb14bee46daecd43519b76028f80bb13d7076ad34ce5f1ccfe6cac8159d13ecf08aa82c7afb4a8560ea1d74bd442e2387f03afe1ce0491
|
7
|
+
data.tar.gz: 240233e6a5eca387b2def2da7660524f28bb11ddbe6d5ee61b9cf829f1baf9ee547ecb411626efa52b8b129434d31e2228a2f7c4c30bacbcf336893ada0f239c
|
data/.github/workflows/rake.yml
CHANGED
@@ -36,7 +36,10 @@ jobs:
|
|
36
36
|
with:
|
37
37
|
ruby-version: ${{ matrix.ruby }}
|
38
38
|
|
39
|
-
-
|
39
|
+
- if: matrix.os == 'macos-latest'
|
40
|
+
run: brew install autoconf automake libtool
|
41
|
+
|
42
|
+
- uses: actions/cache@v2
|
40
43
|
with:
|
41
44
|
path: vendor/bundle
|
42
45
|
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
@@ -64,3 +67,17 @@ jobs:
|
|
64
67
|
run: cinst -y plantuml
|
65
68
|
|
66
69
|
- run: bundle exec rake
|
70
|
+
|
71
|
+
tests-passed:
|
72
|
+
needs: rake
|
73
|
+
runs-on: ubuntu-latest
|
74
|
+
continue-on-error: true
|
75
|
+
steps:
|
76
|
+
- name: Trigger tests passed event
|
77
|
+
uses: Sibz/github-status-action@v1
|
78
|
+
with:
|
79
|
+
authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
80
|
+
context: 'tests-passed-successfully'
|
81
|
+
description: 'Tests passed successfully'
|
82
|
+
state: 'success'
|
83
|
+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -5,7 +5,6 @@ require "pathname"
|
|
5
5
|
require "open-uri"
|
6
6
|
require "isodoc"
|
7
7
|
require "fileutils"
|
8
|
-
require 'asciidoctor/iso/macros'
|
9
8
|
|
10
9
|
module Asciidoctor
|
11
10
|
module ISO
|
@@ -13,10 +12,6 @@ module Asciidoctor
|
|
13
12
|
XML_ROOT_TAG = "iso-standard".freeze
|
14
13
|
XML_NAMESPACE = "https://www.metanorma.org/ns/iso".freeze
|
15
14
|
|
16
|
-
Asciidoctor::Extensions.register do
|
17
|
-
inline_macro Asciidoctor::Iso::TermRefInlineMacro
|
18
|
-
end
|
19
|
-
|
20
15
|
def html_converter(node)
|
21
16
|
IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node))
|
22
17
|
end
|
@@ -49,6 +44,11 @@ module Asciidoctor
|
|
49
44
|
@amd = %w(amendment technical-corrigendum).include? doctype(node)
|
50
45
|
end
|
51
46
|
|
47
|
+
def ol_attrs(node)
|
48
|
+
attr_code(keep_attrs(node).
|
49
|
+
merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
|
50
|
+
end
|
51
|
+
|
52
52
|
def outputs(node, ret)
|
53
53
|
File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
|
54
54
|
presentation_xml_converter(node).convert(@filename + ".xml")
|
@@ -596,6 +596,7 @@
|
|
596
596
|
<ref name="bookmark"/>
|
597
597
|
<ref name="image"/>
|
598
598
|
<ref name="index"/>
|
599
|
+
<ref name="index-xref"/>
|
599
600
|
</choice>
|
600
601
|
</define>
|
601
602
|
<define name="PureTextElement">
|
@@ -728,13 +729,61 @@
|
|
728
729
|
</define>
|
729
730
|
<define name="index">
|
730
731
|
<element name="index">
|
731
|
-
<attribute name="primary"/>
|
732
732
|
<optional>
|
733
|
-
<attribute name="
|
733
|
+
<attribute name="to">
|
734
|
+
<data type="IDREF"/>
|
735
|
+
</attribute>
|
736
|
+
</optional>
|
737
|
+
<element name="primary">
|
738
|
+
<oneOrMore>
|
739
|
+
<ref name="PureTextElement"/>
|
740
|
+
</oneOrMore>
|
741
|
+
</element>
|
742
|
+
<optional>
|
743
|
+
<element name="secondary">
|
744
|
+
<oneOrMore>
|
745
|
+
<ref name="PureTextElement"/>
|
746
|
+
</oneOrMore>
|
747
|
+
</element>
|
748
|
+
</optional>
|
749
|
+
<optional>
|
750
|
+
<element name="tertiary">
|
751
|
+
<oneOrMore>
|
752
|
+
<ref name="PureTextElement"/>
|
753
|
+
</oneOrMore>
|
754
|
+
</element>
|
755
|
+
</optional>
|
756
|
+
</element>
|
757
|
+
</define>
|
758
|
+
<define name="index-xref">
|
759
|
+
<element name="index-xref">
|
760
|
+
<attribute name="also">
|
761
|
+
<data type="boolean"/>
|
762
|
+
</attribute>
|
763
|
+
<element name="primary">
|
764
|
+
<oneOrMore>
|
765
|
+
<ref name="PureTextElement"/>
|
766
|
+
</oneOrMore>
|
767
|
+
</element>
|
768
|
+
<optional>
|
769
|
+
<element name="secondary">
|
770
|
+
<oneOrMore>
|
771
|
+
<ref name="PureTextElement"/>
|
772
|
+
</oneOrMore>
|
773
|
+
</element>
|
734
774
|
</optional>
|
735
775
|
<optional>
|
736
|
-
<
|
776
|
+
<element name="tertiary">
|
777
|
+
<oneOrMore>
|
778
|
+
<ref name="PureTextElement"/>
|
779
|
+
</oneOrMore>
|
780
|
+
</element>
|
737
781
|
</optional>
|
782
|
+
<element name="target">
|
783
|
+
<oneOrMore>
|
784
|
+
<ref name="PureTextElement"/>
|
785
|
+
</oneOrMore>
|
786
|
+
</element>
|
738
787
|
</element>
|
739
788
|
</define>
|
740
789
|
<!-- bare ID element, used for referencing arbitrary spans of text -->
|
@@ -4,7 +4,6 @@ require "htmlentities"
|
|
4
4
|
require "json"
|
5
5
|
require "pathname"
|
6
6
|
require "open-uri"
|
7
|
-
require "asciidoctor/iso/term_lookup_cleanup"
|
8
7
|
|
9
8
|
module Asciidoctor
|
10
9
|
module ISO
|
@@ -89,11 +88,6 @@ module Asciidoctor
|
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
92
|
-
def termdef_cleanup(xmldoc)
|
93
|
-
Asciidoctor::ISO::TermLookupCleanup.new(xmldoc, @log).call
|
94
|
-
super
|
95
|
-
end
|
96
|
-
|
97
91
|
# TODO sort by authors
|
98
92
|
# sort by: doc class (ISO, IEC, other standard (not DOI &c), other
|
99
93
|
# then standard class (docid class other than DOI &c)
|
@@ -18,6 +18,11 @@ module Asciidoctor
|
|
18
18
|
xml.updates_document_type a
|
19
19
|
end
|
20
20
|
|
21
|
+
def metadata_doctype(node, xml)
|
22
|
+
xml.doctype doctype(node)
|
23
|
+
a = node.attr("horizontal") and xml.horizontal a
|
24
|
+
end
|
25
|
+
|
21
26
|
def org_abbrev
|
22
27
|
{ "International Organization for Standardization" => "ISO",
|
23
28
|
"International Electrotechnical Commission" => "IEC" }
|
@@ -80,27 +85,27 @@ module Asciidoctor
|
|
80
85
|
def title_intro(node, t, lang, at)
|
81
86
|
return unless node.attr("title-intro-#{lang}")
|
82
87
|
t.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
|
83
|
-
t1 <<
|
88
|
+
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-intro-#{lang}"))
|
84
89
|
end
|
85
90
|
end
|
86
91
|
|
87
92
|
def title_main(node, t, lang, at)
|
88
93
|
t.title **attr_code(at.merge(type: "title-main")) do |t1|
|
89
|
-
t1 <<
|
94
|
+
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-main-#{lang}"))
|
90
95
|
end
|
91
96
|
end
|
92
97
|
|
93
98
|
def title_part(node, t, lang, at)
|
94
99
|
return unless node.attr("title-part-#{lang}")
|
95
100
|
t.title(**attr_code(at.merge(type: "title-part"))) do |t1|
|
96
|
-
t1 <<
|
101
|
+
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-part-#{lang}"))
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
100
105
|
def title_amd(node, t, lang, at)
|
101
106
|
return unless node.attr("title-amendment-#{lang}")
|
102
107
|
t.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
|
103
|
-
t1 <<
|
108
|
+
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-amendment-#{lang}"))
|
104
109
|
end
|
105
110
|
end
|
106
111
|
|
@@ -113,7 +118,7 @@ module Asciidoctor
|
|
113
118
|
title = "#{title} -- #{part}" if part
|
114
119
|
title = "#{title} -- #{amd}" if amd && @amd
|
115
120
|
t.title **attr_code(at.merge(type: "main")) do |t1|
|
116
|
-
t1 <<
|
121
|
+
t1 << Metanorma::Utils::asciidoc_sub(title)
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
@@ -55,6 +55,13 @@
|
|
55
55
|
<param name="pattern">\i\c*|\c+#\c+</param>
|
56
56
|
</data>
|
57
57
|
</attribute>
|
58
|
+
<optional>
|
59
|
+
<attribute name="to">
|
60
|
+
<data type="string">
|
61
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
62
|
+
</data>
|
63
|
+
</attribute>
|
64
|
+
</optional>
|
58
65
|
<optional>
|
59
66
|
<attribute name="type">
|
60
67
|
<ref name="ReferenceFormat"/>
|
@@ -246,6 +253,12 @@
|
|
246
253
|
<data type="boolean"/>
|
247
254
|
</attribute>
|
248
255
|
</optional>
|
256
|
+
<optional>
|
257
|
+
<attribute name="width"/>
|
258
|
+
</optional>
|
259
|
+
<optional>
|
260
|
+
<ref name="colgroup"/>
|
261
|
+
</optional>
|
249
262
|
<optional>
|
250
263
|
<ref name="tname"/>
|
251
264
|
</optional>
|
@@ -764,6 +777,21 @@
|
|
764
777
|
</define>
|
765
778
|
</include>
|
766
779
|
<!-- end overrides -->
|
780
|
+
<define name="colgroup">
|
781
|
+
<element name="colgroup">
|
782
|
+
<oneOrMore>
|
783
|
+
<ref name="col"/>
|
784
|
+
</oneOrMore>
|
785
|
+
</element>
|
786
|
+
</define>
|
787
|
+
<define name="col">
|
788
|
+
<element name="col">
|
789
|
+
<attribute name="width"/>
|
790
|
+
</element>
|
791
|
+
</define>
|
792
|
+
<define name="BibItemType" combine="choice">
|
793
|
+
<value>internal</value>
|
794
|
+
</define>
|
767
795
|
<define name="TextElement" combine="choice">
|
768
796
|
<ref name="concept"/>
|
769
797
|
</define>
|
@@ -814,6 +842,9 @@
|
|
814
842
|
<data type="boolean"/>
|
815
843
|
</attribute>
|
816
844
|
</optional>
|
845
|
+
<optional>
|
846
|
+
<attribute name="number"/>
|
847
|
+
</optional>
|
817
848
|
<optional>
|
818
849
|
<attribute name="obligation">
|
819
850
|
<choice>
|
@@ -869,9 +900,11 @@
|
|
869
900
|
<element name="code">
|
870
901
|
<text/>
|
871
902
|
</element>
|
872
|
-
<
|
873
|
-
<text
|
874
|
-
|
903
|
+
<optional>
|
904
|
+
<element name="text">
|
905
|
+
<text/>
|
906
|
+
</element>
|
907
|
+
</optional>
|
875
908
|
</element>
|
876
909
|
</define>
|
877
910
|
<define name="standard-document">
|
@@ -1041,6 +1074,9 @@
|
|
1041
1074
|
</choice>
|
1042
1075
|
</attribute>
|
1043
1076
|
</optional>
|
1077
|
+
<optional>
|
1078
|
+
<attribute name="number"/>
|
1079
|
+
</optional>
|
1044
1080
|
<optional>
|
1045
1081
|
<attribute name="type"/>
|
1046
1082
|
</optional>
|
@@ -1094,6 +1130,9 @@
|
|
1094
1130
|
<optional>
|
1095
1131
|
<attribute name="type"/>
|
1096
1132
|
</optional>
|
1133
|
+
<optional>
|
1134
|
+
<attribute name="number"/>
|
1135
|
+
</optional>
|
1097
1136
|
<optional>
|
1098
1137
|
<ref name="section-title"/>
|
1099
1138
|
</optional>
|
@@ -1196,6 +1235,9 @@
|
|
1196
1235
|
<optional>
|
1197
1236
|
<attribute name="type"/>
|
1198
1237
|
</optional>
|
1238
|
+
<optional>
|
1239
|
+
<attribute name="number"/>
|
1240
|
+
</optional>
|
1199
1241
|
<optional>
|
1200
1242
|
<attribute name="obligation">
|
1201
1243
|
<choice>
|
@@ -1524,6 +1566,7 @@
|
|
1524
1566
|
<value>add</value>
|
1525
1567
|
<value>modify</value>
|
1526
1568
|
<value>delete</value>
|
1569
|
+
<value>replace</value>
|
1527
1570
|
</choice>
|
1528
1571
|
</attribute>
|
1529
1572
|
<optional>
|
@@ -1554,6 +1597,11 @@
|
|
1554
1597
|
</optional>
|
1555
1598
|
<optional>
|
1556
1599
|
<element name="newcontent">
|
1600
|
+
<optional>
|
1601
|
+
<attribute name="id">
|
1602
|
+
<data type="ID"/>
|
1603
|
+
</attribute>
|
1604
|
+
</optional>
|
1557
1605
|
<zeroOrMore>
|
1558
1606
|
<ref name="BasicBlock"/>
|
1559
1607
|
</zeroOrMore>
|
@@ -14,9 +14,6 @@
|
|
14
14
|
</define>
|
15
15
|
<define name="clause">
|
16
16
|
<element name="clause">
|
17
|
-
<optional>
|
18
|
-
<attribute name="type"/>
|
19
|
-
</optional>
|
20
17
|
<optional>
|
21
18
|
<attribute name="change">
|
22
19
|
<choice>
|
@@ -34,6 +31,13 @@
|
|
34
31
|
</define>
|
35
32
|
<define name="iso-standard">
|
36
33
|
<element name="iso-standard">
|
34
|
+
<attribute name="version"/>
|
35
|
+
<attribute name="type">
|
36
|
+
<choice>
|
37
|
+
<value>semantic</value>
|
38
|
+
<value>presentation</value>
|
39
|
+
</choice>
|
40
|
+
</attribute>
|
37
41
|
<ref name="bibdata"/>
|
38
42
|
<optional>
|
39
43
|
<ref name="boilerplate"/>
|
@@ -68,7 +72,7 @@
|
|
68
72
|
</optional>
|
69
73
|
<optional>
|
70
74
|
<attribute name="origyr">
|
71
|
-
<
|
75
|
+
<ref name="ISO8601Date"/>
|
72
76
|
</attribute>
|
73
77
|
</optional>
|
74
78
|
<text/>
|
@@ -38,6 +38,9 @@
|
|
38
38
|
</define>
|
39
39
|
<define name="BibDataExtensionType">
|
40
40
|
<ref name="doctype"/>
|
41
|
+
<optional>
|
42
|
+
<ref name="horizontal"/>
|
43
|
+
</optional>
|
41
44
|
<ref name="editorialgroup"/>
|
42
45
|
<zeroOrMore>
|
43
46
|
<ref name="ics"/>
|
@@ -137,22 +140,28 @@
|
|
137
140
|
</choice>
|
138
141
|
</attribute>
|
139
142
|
</optional>
|
143
|
+
<optional>
|
144
|
+
<attribute name="type"/>
|
145
|
+
</optional>
|
140
146
|
<optional>
|
141
147
|
<ref name="section-title"/>
|
142
148
|
</optional>
|
143
|
-
<
|
144
|
-
<
|
145
|
-
<
|
146
|
-
<
|
147
|
-
|
148
|
-
|
149
|
-
<
|
150
|
-
|
151
|
-
|
149
|
+
<group>
|
150
|
+
<choice>
|
151
|
+
<group>
|
152
|
+
<oneOrMore>
|
153
|
+
<ref name="BasicBlock"/>
|
154
|
+
</oneOrMore>
|
155
|
+
<zeroOrMore>
|
156
|
+
<ref name="note"/>
|
157
|
+
</zeroOrMore>
|
158
|
+
</group>
|
159
|
+
<ref name="amend"/>
|
160
|
+
</choice>
|
152
161
|
<oneOrMore>
|
153
162
|
<ref name="clause-subsection"/>
|
154
163
|
</oneOrMore>
|
155
|
-
</
|
164
|
+
</group>
|
156
165
|
</define>
|
157
166
|
<define name="term">
|
158
167
|
<element name="term">
|
@@ -379,6 +388,9 @@
|
|
379
388
|
<data type="anyURI"/>
|
380
389
|
</attribute>
|
381
390
|
</optional>
|
391
|
+
<optional>
|
392
|
+
<ref name="colgroup"/>
|
393
|
+
</optional>
|
382
394
|
<optional>
|
383
395
|
<ref name="tname"/>
|
384
396
|
</optional>
|
@@ -429,6 +441,11 @@
|
|
429
441
|
<ref name="bibliography"/>
|
430
442
|
</element>
|
431
443
|
</define>
|
444
|
+
<define name="horizontal">
|
445
|
+
<element name="horizontal">
|
446
|
+
<data type="boolean"/>
|
447
|
+
</element>
|
448
|
+
</define>
|
432
449
|
<define name="documentnumber">
|
433
450
|
<element name="project-number">
|
434
451
|
<optional>
|
@@ -146,6 +146,83 @@ module Asciidoctor
|
|
146
146
|
"#{iteration} is not a recognised iteration")
|
147
147
|
end
|
148
148
|
|
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
|
+
|
149
226
|
def bibdata_validate(doc)
|
150
227
|
doctype_validate(doc)
|
151
228
|
script_validate(doc)
|
@@ -166,6 +243,7 @@ module Asciidoctor
|
|
166
243
|
locality_erefs_validate(doc.root)
|
167
244
|
bibdata_validate(doc.root)
|
168
245
|
bibitem_validate(doc.root)
|
246
|
+
figure_validate(doc.root)
|
169
247
|
end
|
170
248
|
|
171
249
|
def bibitem_validate(xmldoc)
|