metanorma-iso 1.3.24 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +8 -1
- data/.github/workflows/ubuntu.yml +14 -3
- data/.github/workflows/windows.yml +8 -1
- data/lib/asciidoctor/iso/base.rb +21 -13
- data/lib/asciidoctor/iso/biblio.rng +36 -6
- data/lib/asciidoctor/iso/cleanup.rb +10 -1
- data/lib/asciidoctor/iso/front.rb +16 -110
- data/lib/asciidoctor/iso/front_id.rb +196 -0
- data/lib/asciidoctor/iso/isodoc.rng +444 -1
- data/lib/asciidoctor/iso/isostandard-amd.rng +98 -0
- data/lib/asciidoctor/iso/isostandard.rng +12 -1
- data/lib/asciidoctor/iso/reqt.rng +23 -0
- data/lib/asciidoctor/iso/section.rb +12 -0
- data/lib/asciidoctor/iso/term_lookup_cleanup.rb +7 -10
- data/lib/asciidoctor/iso/validate.rb +40 -23
- data/lib/asciidoctor/iso/validate_requirements.rb +1 -1
- data/lib/asciidoctor/iso/validate_style.rb +6 -5
- data/lib/asciidoctor/iso/validate_title.rb +1 -1
- data/lib/isodoc/iso/base_convert.rb +68 -87
- data/lib/isodoc/iso/html/header.html +5 -1
- data/lib/isodoc/iso/html/html_iso_titlepage.html +25 -16
- data/lib/isodoc/iso/html/isodoc.scss +25 -0
- data/lib/isodoc/iso/html/scripts.html +18 -0
- data/lib/isodoc/iso/html/style-human.scss +23 -0
- data/lib/isodoc/iso/html/style-iso.scss +18 -0
- data/lib/isodoc/iso/html/word_iso_intro.html +4 -0
- data/lib/isodoc/iso/html/word_iso_titlepage.html +21 -0
- data/lib/isodoc/iso/html/wordstyle.scss +45 -4
- data/lib/isodoc/iso/iso.amendment.xsl +5082 -0
- data/lib/isodoc/iso/iso.international-standard.xsl +1226 -530
- data/lib/isodoc/iso/metadata.rb +67 -23
- data/lib/isodoc/iso/pdf_convert.rb +5 -11
- data/lib/isodoc/iso/presentation_xml_convert.rb +13 -0
- data/lib/isodoc/iso/sections.rb +66 -0
- data/lib/isodoc/iso/sts_convert.rb +31 -0
- data/lib/isodoc/iso/xref.rb +111 -0
- data/lib/metanorma-iso.rb +2 -0
- data/lib/metanorma/iso/processor.rb +20 -9
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +5 -2
- data/spec/asciidoctor-iso/amd_spec.rb +726 -0
- data/spec/asciidoctor-iso/base_spec.rb +24 -20
- data/spec/asciidoctor-iso/cleanup_spec.rb +2 -2
- data/spec/asciidoctor-iso/macros_spec.rb +33 -17
- data/spec/asciidoctor-iso/refs_spec.rb +1 -1
- data/spec/asciidoctor-iso/table_spec.rb +1 -1
- data/spec/isodoc/amd_spec.rb +652 -0
- data/spec/isodoc/blocks_spec.rb +112 -27
- data/spec/isodoc/inline_spec.rb +2 -2
- data/spec/isodoc/metadata_spec.rb +88 -4
- data/spec/isodoc/postproc_spec.rb +11 -11
- data/spec/isodoc/ref_spec.rb +7 -7
- data/spec/isodoc/section_spec.rb +28 -1
- data/spec/isodoc/table_spec.rb +29 -29
- data/spec/isodoc/terms_spec.rb +4 -4
- data/spec/isodoc/xref_spec.rb +32 -26
- data/spec/metanorma/processor_spec.rb +2 -2
- data/spec/spec_helper.rb +11 -0
- metadata +61 -11
@@ -0,0 +1,98 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar ns="https://www.metanorma.org/ns/iso" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!-- default namespace isostandard = "https://www.metanorma.com/ns/iso" -->
|
4
|
+
<include href="isostandard.rng">
|
5
|
+
<start>
|
6
|
+
<ref name="iso-standard"/>
|
7
|
+
</start>
|
8
|
+
<define name="sections">
|
9
|
+
<element name="sections">
|
10
|
+
<oneOrMore>
|
11
|
+
<ref name="clause"/>
|
12
|
+
</oneOrMore>
|
13
|
+
</element>
|
14
|
+
</define>
|
15
|
+
<define name="clause">
|
16
|
+
<element name="clause">
|
17
|
+
<optional>
|
18
|
+
<attribute name="type"/>
|
19
|
+
</optional>
|
20
|
+
<optional>
|
21
|
+
<attribute name="change">
|
22
|
+
<choice>
|
23
|
+
<value>add</value>
|
24
|
+
<value>delete</value>
|
25
|
+
<value>modify</value>
|
26
|
+
</choice>
|
27
|
+
</attribute>
|
28
|
+
</optional>
|
29
|
+
<optional>
|
30
|
+
<attribute name="locality"/>
|
31
|
+
</optional>
|
32
|
+
<ref name="Clause-Section"/>
|
33
|
+
</element>
|
34
|
+
</define>
|
35
|
+
<define name="iso-standard">
|
36
|
+
<element name="iso-standard">
|
37
|
+
<ref name="bibdata"/>
|
38
|
+
<optional>
|
39
|
+
<ref name="boilerplate"/>
|
40
|
+
</optional>
|
41
|
+
<ref name="preface"/>
|
42
|
+
<oneOrMore>
|
43
|
+
<ref name="sections"/>
|
44
|
+
</oneOrMore>
|
45
|
+
</element>
|
46
|
+
</define>
|
47
|
+
<define name="documentnumber">
|
48
|
+
<element name="project-number">
|
49
|
+
<optional>
|
50
|
+
<attribute name="part">
|
51
|
+
<data type="int"/>
|
52
|
+
</attribute>
|
53
|
+
</optional>
|
54
|
+
<optional>
|
55
|
+
<attribute name="subpart">
|
56
|
+
<data type="int"/>
|
57
|
+
</attribute>
|
58
|
+
</optional>
|
59
|
+
<optional>
|
60
|
+
<attribute name="amendment">
|
61
|
+
<data type="int"/>
|
62
|
+
</attribute>
|
63
|
+
</optional>
|
64
|
+
<optional>
|
65
|
+
<attribute name="corrigendum">
|
66
|
+
<data type="int"/>
|
67
|
+
</attribute>
|
68
|
+
</optional>
|
69
|
+
<optional>
|
70
|
+
<attribute name="origyr">
|
71
|
+
<data type="int"/>
|
72
|
+
</attribute>
|
73
|
+
</optional>
|
74
|
+
<text/>
|
75
|
+
</element>
|
76
|
+
</define>
|
77
|
+
<define name="BibDataExtensionType">
|
78
|
+
<ref name="doctype"/>
|
79
|
+
<ref name="editorialgroup"/>
|
80
|
+
<zeroOrMore>
|
81
|
+
<ref name="ics"/>
|
82
|
+
</zeroOrMore>
|
83
|
+
<ref name="structuredidentifier"/>
|
84
|
+
<optional>
|
85
|
+
<ref name="stagename"/>
|
86
|
+
</optional>
|
87
|
+
<optional>
|
88
|
+
<ref name="updates_document_type"/>
|
89
|
+
</optional>
|
90
|
+
</define>
|
91
|
+
</include>
|
92
|
+
<!-- end overrides -->
|
93
|
+
<define name="updates_document_type">
|
94
|
+
<element name="updates-document-type">
|
95
|
+
<ref name="DocumentType"/>
|
96
|
+
</element>
|
97
|
+
</define>
|
98
|
+
</grammar>
|
@@ -91,6 +91,12 @@
|
|
91
91
|
</define>
|
92
92
|
<define name="sections">
|
93
93
|
<element name="sections">
|
94
|
+
<zeroOrMore>
|
95
|
+
<choice>
|
96
|
+
<ref name="note"/>
|
97
|
+
<ref name="admonition"/>
|
98
|
+
</choice>
|
99
|
+
</zeroOrMore>
|
94
100
|
<ref name="clause"/>
|
95
101
|
<optional>
|
96
102
|
<choice>
|
@@ -263,6 +269,8 @@
|
|
263
269
|
<value>publicly-available-specification</value>
|
264
270
|
<value>international-workshop-agreement</value>
|
265
271
|
<value>guide</value>
|
272
|
+
<value>amendment</value>
|
273
|
+
<value>technical-corrigendum</value>
|
266
274
|
</choice>
|
267
275
|
</define>
|
268
276
|
<define name="structuredidentifier">
|
@@ -354,6 +362,9 @@
|
|
354
362
|
<data type="boolean"/>
|
355
363
|
</attribute>
|
356
364
|
</optional>
|
365
|
+
<optional>
|
366
|
+
<attribute name="number"/>
|
367
|
+
</optional>
|
357
368
|
<optional>
|
358
369
|
<attribute name="subsequence"/>
|
359
370
|
</optional>
|
@@ -510,7 +521,7 @@
|
|
510
521
|
</attribute>
|
511
522
|
</optional>
|
512
523
|
<oneOrMore>
|
513
|
-
<ref name="
|
524
|
+
<ref name="BasicBlock"/>
|
514
525
|
</oneOrMore>
|
515
526
|
</element>
|
516
527
|
</define>
|
@@ -30,9 +30,22 @@
|
|
30
30
|
<data type="boolean"/>
|
31
31
|
</attribute>
|
32
32
|
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="number"/>
|
35
|
+
</optional>
|
33
36
|
<optional>
|
34
37
|
<attribute name="subsequence"/>
|
35
38
|
</optional>
|
39
|
+
<optional>
|
40
|
+
<attribute name="keep-with-next">
|
41
|
+
<data type="boolean"/>
|
42
|
+
</attribute>
|
43
|
+
</optional>
|
44
|
+
<optional>
|
45
|
+
<attribute name="keep-lines-together">
|
46
|
+
<data type="boolean"/>
|
47
|
+
</attribute>
|
48
|
+
</optional>
|
36
49
|
<attribute name="id">
|
37
50
|
<data type="ID"/>
|
38
51
|
</attribute>
|
@@ -141,6 +154,16 @@
|
|
141
154
|
<data type="boolean"/>
|
142
155
|
</attribute>
|
143
156
|
</optional>
|
157
|
+
<optional>
|
158
|
+
<attribute name="keep-with-next">
|
159
|
+
<data type="boolean"/>
|
160
|
+
</attribute>
|
161
|
+
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="keep-lines-together">
|
164
|
+
<data type="boolean"/>
|
165
|
+
</attribute>
|
166
|
+
</optional>
|
144
167
|
<oneOrMore>
|
145
168
|
<ref name="BasicBlock"/>
|
146
169
|
</oneOrMore>
|
@@ -35,6 +35,18 @@ module Asciidoctor
|
|
35
35
|
xml_section << content
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def section_attributes(node)
|
40
|
+
super.merge(
|
41
|
+
change: @amd ? node.attr("change") : nil,
|
42
|
+
locality: @amd ? node.attr("locality") : nil,
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def sectiontype(node, level = true)
|
47
|
+
return nil if @amd
|
48
|
+
super
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
40
52
|
end
|
@@ -31,23 +31,20 @@ module Asciidoctor
|
|
31
31
|
remove_missing_ref(node, target)
|
32
32
|
next
|
33
33
|
end
|
34
|
-
|
35
34
|
modify_ref_node(node, target)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
38
|
def remove_missing_ref(node, target)
|
40
|
-
log.add('AsciiDoc Input',
|
41
|
-
node,
|
39
|
+
log.add('AsciiDoc Input', node,
|
42
40
|
%(Error: Term reference in `term[#{target}]` missing: \
|
43
41
|
"#{target}" is not defined in document))
|
44
|
-
# Term ref have parentess around it - (ref),
|
45
|
-
# if no target remove parentes and render as text
|
46
|
-
node.next.remove
|
47
42
|
term_name_node = node.previous.previous
|
48
43
|
term_name_node.remove
|
49
|
-
|
50
|
-
|
44
|
+
term_name_node.name = "strong"
|
45
|
+
term_name_node.children.first.content =
|
46
|
+
%(term "#{term_name_node.text}" not resolved)
|
47
|
+
node.add_previous_sibling(term_name_node)
|
51
48
|
node.remove
|
52
49
|
end
|
53
50
|
|
@@ -60,15 +57,15 @@ module Asciidoctor
|
|
60
57
|
|
61
58
|
def replace_automatic_generated_ids_terms
|
62
59
|
xmldoc.xpath('//term').each.with_object({}) do |term_node, res|
|
63
|
-
next if AUTOMATIC_GENERATED_ID_REGEXP.match(term_node['id']).nil?
|
64
|
-
|
65
60
|
normalize_id_and_memorize(term_node, res, './preferred')
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
69
64
|
def normalize_id_and_memorize(term_node, res_table, text_selector)
|
70
65
|
term_text = normalize_ref_id(term_node.at(text_selector).text)
|
66
|
+
unless AUTOMATIC_GENERATED_ID_REGEXP.match(term_node['id']).nil?
|
71
67
|
term_node['id'] = unique_text_id(term_text)
|
68
|
+
end
|
72
69
|
res_table[term_text] = term_node['id']
|
73
70
|
end
|
74
71
|
|
@@ -24,12 +24,14 @@ module Asciidoctor
|
|
24
24
|
def isosubgroup_validate(root)
|
25
25
|
root.xpath("//technical-committee/@type").each do |t|
|
26
26
|
unless %w{TC PC JTC JPC}.include? t.text
|
27
|
-
@log.add("Document Attributes", nil,
|
27
|
+
@log.add("Document Attributes", nil,
|
28
|
+
"invalid technical committee type #{t}")
|
28
29
|
end
|
29
30
|
end
|
30
31
|
root.xpath("//subcommittee/@type").each do |t|
|
31
32
|
unless %w{SC JSC}.include? t.text
|
32
|
-
@log.add("Document Attributes", nil,
|
33
|
+
@log.add("Document Attributes", nil,
|
34
|
+
"invalid subcommittee type #{t}")
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -39,10 +41,12 @@ module Asciidoctor
|
|
39
41
|
root.xpath("//xref").each do |t|
|
40
42
|
# does not deal with preceding text marked up
|
41
43
|
preceding = t.at("./preceding-sibling::text()[last()]")
|
42
|
-
next unless !preceding.nil? &&
|
44
|
+
next unless !preceding.nil? &&
|
45
|
+
/\b(see| refer to)\s*$/mi.match(preceding)
|
43
46
|
(target = root.at("//*[@id = '#{t['target']}']")) || next
|
44
47
|
if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
|
45
|
-
@log.add("Style", t,
|
48
|
+
@log.add("Style", t,
|
49
|
+
"'see #{t['target']}' is pointing to a normative section")
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -51,13 +55,16 @@ module Asciidoctor
|
|
51
55
|
def see_erefs_validate(root)
|
52
56
|
root.xpath("//eref").each do |t|
|
53
57
|
preceding = t.at("./preceding-sibling::text()[last()]")
|
54
|
-
next unless !preceding.nil? &&
|
58
|
+
next unless !preceding.nil? &&
|
59
|
+
/\b(see|refer to)\s*$/mi.match(preceding)
|
55
60
|
unless target = root.at("//*[@id = '#{t['bibitemid']}']")
|
56
|
-
@log.add("Bibliography", t,
|
61
|
+
@log.add("Bibliography", t,
|
62
|
+
"'#{t} is not pointing to a real reference")
|
57
63
|
next
|
58
64
|
end
|
59
65
|
if target.at("./ancestor::references[@normative = 'true']")
|
60
|
-
@log.add("Style", t,
|
66
|
+
@log.add("Style", t,
|
67
|
+
"'see #{t}' is pointing to a normative reference")
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
@@ -67,8 +74,9 @@ module Asciidoctor
|
|
67
74
|
root.xpath("//eref[descendant::locality]").each do |t|
|
68
75
|
if /^(ISO|IEC)/.match t["citeas"]
|
69
76
|
unless /:[ ]?(\d+{4}|–)$/.match t["citeas"]
|
70
|
-
@log.add("Style", t,
|
71
|
-
|
77
|
+
@log.add("Style", t,
|
78
|
+
"undated reference #{t['citeas']} should not contain "\
|
79
|
+
"specific elements")
|
72
80
|
end
|
73
81
|
end
|
74
82
|
end
|
@@ -105,32 +113,37 @@ module Asciidoctor
|
|
105
113
|
doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
|
106
114
|
%w(international-standard technical-specification technical-report
|
107
115
|
publicly-available-specification international-workshop-agreement
|
108
|
-
guide).include? doctype or
|
109
|
-
@log.add("Document Attributes", nil,
|
116
|
+
guide amendment technical-corrigendum).include? doctype or
|
117
|
+
@log.add("Document Attributes", nil,
|
118
|
+
"#{doctype} is not a recognised document type")
|
110
119
|
end
|
111
120
|
|
112
121
|
def script_validate(xmldoc)
|
113
122
|
script = xmldoc&.at("//bibdata/script")&.text
|
114
123
|
script == "Latn" or
|
115
|
-
@log.add("Document Attributes", nil,
|
124
|
+
@log.add("Document Attributes", nil,
|
125
|
+
"#{script} is not a recognised script")
|
116
126
|
end
|
117
127
|
|
118
128
|
def stage_validate(xmldoc)
|
119
129
|
stage = xmldoc&.at("//bibdata/status/stage")&.text
|
120
130
|
%w(00 10 20 30 40 50 60 90 95).include? stage or
|
121
|
-
@log.add("Document Attributes", nil,
|
131
|
+
@log.add("Document Attributes", nil,
|
132
|
+
"#{stage} is not a recognised stage")
|
122
133
|
end
|
123
134
|
|
124
135
|
def substage_validate(xmldoc)
|
125
136
|
substage = xmldoc&.at("//bibdata/status/substage")&.text or return
|
126
137
|
%w(00 20 60 90 92 93 98 99).include? substage or
|
127
|
-
@log.add("Document Attributes", nil,
|
138
|
+
@log.add("Document Attributes", nil,
|
139
|
+
"#{substage} is not a recognised substage")
|
128
140
|
end
|
129
141
|
|
130
142
|
def iteration_validate(xmldoc)
|
131
143
|
iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
|
132
144
|
/^\d+/.match(iteration) or
|
133
|
-
@log.add("Document Attributes", nil,
|
145
|
+
@log.add("Document Attributes", nil,
|
146
|
+
"#{iteration} is not a recognised iteration")
|
134
147
|
end
|
135
148
|
|
136
149
|
def bibdata_validate(doc)
|
@@ -157,20 +170,24 @@ module Asciidoctor
|
|
157
170
|
|
158
171
|
def bibitem_validate(xmldoc)
|
159
172
|
xmldoc.xpath("//bibitem[date/on = '–']").each do |b|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
found or
|
165
|
-
@log.add("Style", b, "Reference #{b&.at("./@id")&.text} does not have an "\
|
166
|
-
"associated footnote indicating unpublished status")
|
173
|
+
b.at("./note[@type = 'ISO DATE']") or
|
174
|
+
@log.add("Style", b,
|
175
|
+
"Reference #{b&.at("./@id")&.text} does not have an "\
|
176
|
+
"associated footnote indicating unpublished status")
|
167
177
|
end
|
168
178
|
end
|
169
179
|
|
170
180
|
def validate(doc)
|
171
181
|
content_validate(doc)
|
182
|
+
doctype = doc&.at("//bibdata/ext/doctype")&.text
|
183
|
+
schema = case doctype
|
184
|
+
when "amendment", "technical-corrigendum" # @amd
|
185
|
+
"isostandard-amd.rng"
|
186
|
+
else
|
187
|
+
"isostandard.rng"
|
188
|
+
end
|
172
189
|
schema_validate(formattedstr_strip(doc.dup),
|
173
|
-
File.join(File.dirname(__FILE__),
|
190
|
+
File.join(File.dirname(__FILE__), schema))
|
174
191
|
end
|
175
192
|
end
|
176
193
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "metanorma-standoc"
|
2
2
|
require "nokogiri"
|
3
|
-
require "
|
3
|
+
require "tokenizer"
|
4
4
|
|
5
5
|
module Asciidoctor
|
6
6
|
module ISO
|
@@ -70,7 +70,7 @@ module Asciidoctor
|
|
70
70
|
# and a negative match on its preceding token
|
71
71
|
def style_two_regex_not_prev(n, text, re, re_prev, warning)
|
72
72
|
return if text.nil?
|
73
|
-
arr =
|
73
|
+
arr = Tokenizer::WhitespaceTokenizer.new.tokenize(text)
|
74
74
|
arr.each_index do |i|
|
75
75
|
m = re.match arr[i]
|
76
76
|
m_prev = i.zero? ? nil : re_prev.match(arr[i - 1])
|
@@ -91,9 +91,10 @@ module Asciidoctor
|
|
91
91
|
# ISO/IEC DIR 2, 9.1
|
92
92
|
# ISO/IEC DIR 2, Table B.1
|
93
93
|
def style_number(n, t)
|
94
|
-
style_two_regex_not_prev(
|
95
|
-
|
96
|
-
|
94
|
+
style_two_regex_not_prev(
|
95
|
+
n, t, /^(?<num>-?[0-9]{4,}[,0-9]*)$/,
|
96
|
+
%r{\b(ISO|IEC|IEEE/|(in|January|February|March|April|May|June|August|September|October|November|December)\b)$},
|
97
|
+
"number not broken up in threes")
|
97
98
|
style_regex(/\b(?<num>[0-9]+\.[0-9]+)/i,
|
98
99
|
"possible decimal point", n, t)
|
99
100
|
style_regex(/\b(?<num>billion[s]?)\b/i,
|
@@ -36,7 +36,7 @@ module Asciidoctor
|
|
36
36
|
|
37
37
|
# ISO/IEC DIR 2, 11.4
|
38
38
|
def title_subpart_validate(root)
|
39
|
-
docid = root.at("//bibdata/docidentifier[@type = '
|
39
|
+
docid = root.at("//bibdata/docidentifier[@type = 'ISO']")
|
40
40
|
subpart = /-\d+-\d+/.match docid
|
41
41
|
iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
|
42
42
|
"organization[abbreviation = 'IEC' or "\
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "isodoc"
|
2
2
|
require_relative "metadata"
|
3
|
+
require_relative "sections"
|
4
|
+
require_relative "xref"
|
3
5
|
require "fileutils"
|
4
6
|
|
5
7
|
module IsoDoc
|
@@ -9,43 +11,25 @@ module IsoDoc
|
|
9
11
|
@meta = Metadata.new(lang, script, labels)
|
10
12
|
end
|
11
13
|
|
12
|
-
def
|
13
|
-
|
14
|
+
def xref_init(lang, script, klass, labels, options)
|
15
|
+
@xrefs = Xref.new(lang, script, klass, labels, options)
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
title_attr = { class: "IntroTitle" }
|
20
|
-
page_break(out)
|
21
|
-
out.div **{ class: "Section3", id: f["id"] } do |div|
|
22
|
-
clause_name(num, @introduction_lbl, div, title_attr)
|
23
|
-
f.elements.each do |e|
|
24
|
-
parse(e, div) unless e.name == "title"
|
25
|
-
end
|
26
|
-
end
|
18
|
+
def amd(docxml)
|
19
|
+
doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
|
20
|
+
%w(amendment technical-corrigendum).include? doctype
|
27
21
|
end
|
28
22
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl }
|
34
|
-
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
23
|
+
def convert1(docxml, filename, dir)
|
24
|
+
if amd(docxml)
|
25
|
+
@oldsuppressheadingnumbers = @suppressheadingnumbers
|
26
|
+
@suppressheadingnumbers = true
|
35
27
|
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def initial_anchor_names(d)
|
39
28
|
super
|
40
|
-
introduction_names(d.at(ns("//introduction")))
|
41
29
|
end
|
42
30
|
|
43
|
-
|
44
|
-
|
45
|
-
return if clause.nil?
|
46
|
-
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
47
|
-
section_names1(c, "0.#{i + 1}", 2)
|
48
|
-
end
|
31
|
+
def implicit_reference(b)
|
32
|
+
b&.at(ns("./docidentifier"))&.text == "IEV"
|
49
33
|
end
|
50
34
|
|
51
35
|
# terms not defined in standoc
|
@@ -57,36 +41,6 @@ module IsoDoc
|
|
57
41
|
end
|
58
42
|
end
|
59
43
|
|
60
|
-
def annex_names(clause, num)
|
61
|
-
appendix_names(clause, num)
|
62
|
-
super
|
63
|
-
end
|
64
|
-
|
65
|
-
def appendix_names(clause, num)
|
66
|
-
clause.xpath(ns("./appendix")).each_with_index do |c, i|
|
67
|
-
@anchors[c["id"]] = anchor_struct(i + 1, nil, @appendix_lbl, "clause")
|
68
|
-
@anchors[c["id"]][:level] = 2
|
69
|
-
@anchors[c["id"]][:container] = clause["id"]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def section_names1(clause, num, level)
|
74
|
-
@anchors[clause["id"]] =
|
75
|
-
{ label: num, level: level, xref: num }
|
76
|
-
# subclauses are not prefixed with "Clause"
|
77
|
-
clause.xpath(ns("./clause | ./terms | ./term | ./definitions | ./references")).
|
78
|
-
each_with_index do |c, i|
|
79
|
-
section_names1(c, "#{num}.#{i + 1}", level + 1)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def annex_names1(clause, num, level)
|
84
|
-
@anchors[clause["id"]] = { label: num, xref: num, level: level }
|
85
|
-
clause.xpath(ns("./clause | ./references")).each_with_index do |c, i|
|
86
|
-
annex_names1(c, "#{num}.#{i + 1}", level + 1)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
44
|
def eref_localities1_zh(target, type, from, to, delim)
|
91
45
|
subsection = from&.text&.match(/\./)
|
92
46
|
ret = (delim == ";") ? ";" : (type == "list") ? "" : delim
|
@@ -100,6 +54,7 @@ module IsoDoc
|
|
100
54
|
end
|
101
55
|
|
102
56
|
def eref_localities1(target, type, from, to, delim, lang = "en")
|
57
|
+
return "" if type == "anchor"
|
103
58
|
subsection = from&.text&.match(/\./)
|
104
59
|
type = type.downcase
|
105
60
|
return l10n(eref_localities1_zh(target, type, from, to, delim)) if lang == "zh"
|
@@ -114,12 +69,12 @@ module IsoDoc
|
|
114
69
|
end
|
115
70
|
|
116
71
|
def prefix_container(container, linkend, target)
|
117
|
-
delim = anchor(target, :type) == "listitem" ? " " : ", "
|
118
|
-
l10n(anchor(container, :xref) + delim + linkend)
|
72
|
+
delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
|
73
|
+
l10n(@xrefs.anchor(container, :xref) + delim + linkend)
|
119
74
|
end
|
120
75
|
|
121
76
|
def example_span_label(node, div, name)
|
122
|
-
n =
|
77
|
+
n = @xrefs.get[node["id"]]
|
123
78
|
div.span **{ class: "example_label" } do |p|
|
124
79
|
lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
|
125
80
|
l10n("#{@example_lbl} #{n[:label]}")
|
@@ -191,23 +146,6 @@ module IsoDoc
|
|
191
146
|
""
|
192
147
|
end
|
193
148
|
|
194
|
-
def format_ref(ref, prefix, isopub, date, allparts)
|
195
|
-
ref = ref.sub(/ \(All Parts\)/i, "")
|
196
|
-
ref = docid_prefix(prefix, ref)
|
197
|
-
return "[#{ref}]" if /^\d+$/.match(ref) && !prefix &&
|
198
|
-
!/^\[.*\]$/.match(ref)
|
199
|
-
ref
|
200
|
-
end
|
201
|
-
|
202
|
-
def table_footnote_reference_format(a)
|
203
|
-
a.content = a.content + ")"
|
204
|
-
end
|
205
|
-
|
206
|
-
def clause_parse_title(node, div, c1, out)
|
207
|
-
return inline_header_title(out, node, c1) if c1.nil?
|
208
|
-
super
|
209
|
-
end
|
210
|
-
|
211
149
|
def cleanup(docxml)
|
212
150
|
super
|
213
151
|
table_th_center(docxml)
|
@@ -221,14 +159,57 @@ module IsoDoc
|
|
221
159
|
end
|
222
160
|
end
|
223
161
|
|
224
|
-
def
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
162
|
+
def formula_where(dl, out)
|
163
|
+
return if dl.nil?
|
164
|
+
return super unless (dl&.xpath(ns("./dt"))&.size == 1 &&
|
165
|
+
dl&.at(ns("./dd"))&.elements&.size == 1 &&
|
166
|
+
dl&.at(ns("./dd/p")))
|
167
|
+
out.span **{ class: "zzMoveToFollowing" } do |s|
|
168
|
+
s << "#{@where_lbl} "
|
169
|
+
dl.at(ns("./dt")).children.each { |n| parse(n, s) }
|
170
|
+
s << " "
|
171
|
+
end
|
172
|
+
parse(dl.at(ns("./dd/p")), out)
|
173
|
+
end
|
174
|
+
|
175
|
+
def admonition_parse(node, out)
|
176
|
+
type = node["type"]
|
177
|
+
name = admonition_name(node, type)
|
178
|
+
out.div **{ id: node["id"], class: admonition_class(node) } do |div|
|
179
|
+
node.first_element_child.name == "p" ?
|
180
|
+
admonition_p_parse(node, div, name) : admonition_parse1(node, div, name)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def admonition_parse1(node, div, name)
|
185
|
+
div.p do |p|
|
186
|
+
admonition_name_parse(node, p, name) if name
|
187
|
+
end
|
188
|
+
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
189
|
+
end
|
190
|
+
|
191
|
+
def admonition_p_parse(node, div, name)
|
192
|
+
div.p do |p|
|
193
|
+
admonition_name_parse(node, p, name) if name
|
194
|
+
node.first_element_child.children.each { |n| parse(n, p) }
|
195
|
+
end
|
196
|
+
node.element_children[1..-1].each { |n| parse(n, div) }
|
197
|
+
end
|
198
|
+
|
199
|
+
def admonition_name_parse(_node, div, name)
|
200
|
+
name.children.each { |n| parse(n, div) }
|
201
|
+
div << " — "
|
202
|
+
end
|
203
|
+
|
204
|
+
def figure_name_parse(node, div, name)
|
205
|
+
lbl = @xrefs.anchor(node['id'], :label, false)
|
206
|
+
lbl = nil if labelled_ancestor(node) && node.ancestors("figure").empty?
|
207
|
+
return if lbl.nil? && name.nil?
|
208
|
+
div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
|
209
|
+
figname = node.parent.name == "figure" ? "" : "#{@figure_lbl} "
|
210
|
+
lbl.nil? or p << l10n("#{figname}#{lbl}")
|
211
|
+
name and !lbl.nil? and p << " — "
|
212
|
+
name and name.children.each { |n| parse(n, div) }
|
232
213
|
end
|
233
214
|
end
|
234
215
|
end
|