metanorma-iso 2.1.9 → 2.2.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/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 +0 -1
- data/lib/isodoc/iso/init.rb +15 -10
- data/lib/isodoc/iso/iso.amendment.xsl +110 -15
- data/lib/isodoc/iso/iso.international-standard.xsl +110 -15
- data/lib/isodoc/iso/metadata.rb +1 -1
- data/lib/isodoc/iso/presentation_xref.rb +1 -0
- data/lib/isodoc/iso/word_convert.rb +6 -0
- data/lib/isodoc/iso/xref.rb +43 -99
- data/lib/isodoc/iso/xref_section.rb +79 -0
- data/lib/metanorma/iso/biblio.rng +32 -1
- data/lib/metanorma/iso/front_id.rb +2 -2
- data/lib/metanorma/iso/isodoc.rng +9 -0
- data/lib/metanorma/iso/isostandard.rng +3 -0
- data/lib/metanorma/iso/validate.rb +1 -1
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/metanorma/iso.rb +0 -1
- data/lib/metanorma/requirements/modspec.rb +74 -8
- data/lib/metanorma-iso.rb +1 -0
- data/lib/relaton/render/config.yml +53 -1
- data/metanorma-iso.gemspec +1 -1
- data/spec/isodoc/i18n_spec.rb +2 -2
- data/spec/isodoc/ref_spec.rb +4 -4
- data/spec/metanorma/base_spec.rb +3 -3
- data/spec/metanorma/refs_spec.rb +7 -7
- data/spec/relaton/render_spec.rb +568 -0
- data/spec/requirements/requirement_components_spec.rb +622 -0
- data/spec/requirements/requirements_spec.rb +436 -54
- data/spec/requirements/xref_spec.rb +41 -35
- data/spec/vcr_cassettes/docrels.yml +33 -33
- data/spec/vcr_cassettes/withdrawn_iso.yml +29 -29
- metadata +7 -4
data/lib/isodoc/iso/xref.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "xref_section"
|
2
|
+
|
1
3
|
module IsoDoc
|
2
4
|
module Iso
|
3
5
|
class Counter < IsoDoc::XrefGen::Counter
|
@@ -17,21 +19,20 @@ module IsoDoc
|
|
17
19
|
|
18
20
|
def initial_anchor_names_amd(doc)
|
19
21
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
20
|
-
|
21
|
-
|
22
|
+
["//preface/*", "//sections/clause"].each do |xpath|
|
23
|
+
doc.xpath(ns(xpath)).each do |c|
|
24
|
+
c.element? and preface_names(c)
|
25
|
+
end
|
22
26
|
end
|
23
|
-
doc.xpath(ns("//sections/clause")).each do |c|
|
24
|
-
c.element? and preface_names(c)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
if @parse_settings.empty?
|
28
|
-
sequential_asset_names(doc.xpath(ns("//preface/*")))
|
29
|
-
middle_section_asset_names(doc)
|
30
|
-
termnote_anchor_names(doc)
|
31
|
-
termexample_anchor_names(doc)
|
32
27
|
end
|
33
28
|
end
|
34
29
|
|
30
|
+
def asset_anchor_names(doc)
|
31
|
+
super
|
32
|
+
@parse_settings.empty? or return
|
33
|
+
sequential_asset_names(doc.xpath(ns("//preface/*")))
|
34
|
+
end
|
35
|
+
|
35
36
|
def initial_anchor_names1(doc)
|
36
37
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
37
38
|
doc.xpath(ns("//preface/*")).each do |c|
|
@@ -47,81 +48,6 @@ module IsoDoc
|
|
47
48
|
n = section_names(c, n, 1)
|
48
49
|
end
|
49
50
|
end
|
50
|
-
if @parse_settings.empty?
|
51
|
-
middle_section_asset_names(doc)
|
52
|
-
termnote_anchor_names(doc)
|
53
|
-
termexample_anchor_names(doc)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# we can reference 0-number clauses in introduction
|
58
|
-
def introduction_names(clause)
|
59
|
-
return if clause.nil?
|
60
|
-
|
61
|
-
clause.at(ns("./clause")) and
|
62
|
-
@anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
|
63
|
-
xref: clause.at(ns("./title"))&.text }
|
64
|
-
i = Counter.new
|
65
|
-
clause.xpath(ns("./clause")).each do |c|
|
66
|
-
i.increment(c)
|
67
|
-
section_names1(c, "0.#{i.print}", 2)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def annex_names(clause, num)
|
72
|
-
appendix_names(clause, num)
|
73
|
-
super
|
74
|
-
end
|
75
|
-
|
76
|
-
def appendix_names(clause, _num)
|
77
|
-
i = Counter.new
|
78
|
-
clause.xpath(ns("./appendix")).each do |c|
|
79
|
-
i.increment(c)
|
80
|
-
@anchors[c["id"]] =
|
81
|
-
anchor_struct(i.print, nil, @labels["appendix"],
|
82
|
-
"clause").merge(level: 2, subtype: "annex",
|
83
|
-
container: clause["id"])
|
84
|
-
j = Counter.new
|
85
|
-
c.xpath(ns("./clause | ./references")).each do |c1|
|
86
|
-
j.increment(c1)
|
87
|
-
lbl = "#{@labels['appendix']} #{i.print}.#{j.print}"
|
88
|
-
appendix_names1(c1, l10n(lbl), 3, clause["id"])
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# subclauses are not prefixed with "Clause"
|
94
|
-
# retaining subtype for the semantics
|
95
|
-
def section_names1(clause, num, level)
|
96
|
-
@anchors[clause["id"]] =
|
97
|
-
{ label: num, level: level, xref: num, subtype: "clause" }
|
98
|
-
i = Counter.new
|
99
|
-
clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
|
100
|
-
"./references"))
|
101
|
-
.each do |c|
|
102
|
-
i.increment(c)
|
103
|
-
section_names1(c, "#{num}.#{i.print}", level + 1)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def annex_names1(clause, num, level)
|
108
|
-
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
109
|
-
subtype: "annex" }
|
110
|
-
i = Counter.new
|
111
|
-
clause.xpath(ns("./clause | ./references")).each do |c|
|
112
|
-
i.increment(c)
|
113
|
-
annex_names1(c, "#{num}.#{i.print}", level + 1)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def appendix_names1(clause, num, level, container)
|
118
|
-
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
119
|
-
container: container }
|
120
|
-
i = Counter.new
|
121
|
-
clause.xpath(ns("./clause | ./references")).each do |c|
|
122
|
-
i.increment(c)
|
123
|
-
appendix_names1(c, "#{num}.#{i.print}", level + 1, container)
|
124
|
-
end
|
125
51
|
end
|
126
52
|
|
127
53
|
def hierarchical_formula_names(clause, num)
|
@@ -137,10 +63,10 @@ module IsoDoc
|
|
137
63
|
end
|
138
64
|
end
|
139
65
|
|
140
|
-
def figure_anchor(elem, sublabel, label)
|
66
|
+
def figure_anchor(elem, sublabel, label, klass)
|
141
67
|
@anchors[elem["id"]] = anchor_struct(
|
142
68
|
(sublabel ? "#{label} #{sublabel}" : label),
|
143
|
-
nil, @labels[
|
69
|
+
nil, @labels[klass] || klass.capitalize, klass, elem["unnumbered"]
|
144
70
|
)
|
145
71
|
sublabel && elem["unnumbered"] != "true" and
|
146
72
|
@anchors[elem["id"]][:label] = sublabel
|
@@ -148,27 +74,49 @@ module IsoDoc
|
|
148
74
|
|
149
75
|
def sequential_figure_names(clause)
|
150
76
|
j = 0
|
151
|
-
clause.xpath(ns(
|
77
|
+
clause.xpath(ns(FIGURE_NO_CLASS)).noblank
|
152
78
|
.each_with_object(IsoDoc::XrefGen::Counter.new) do |t, c|
|
153
79
|
j = subfigure_increment(j, c, t)
|
154
80
|
sublabel = j.zero? ? nil : "#{(j + 96).chr})"
|
155
|
-
|
81
|
+
figure_anchor(t, sublabel, c.print, "figure")
|
82
|
+
end
|
83
|
+
sequential_figure_class_names(clause)
|
84
|
+
end
|
156
85
|
|
157
|
-
|
86
|
+
def sequential_figure_class_names(clause)
|
87
|
+
c = {}
|
88
|
+
j = 0
|
89
|
+
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
90
|
+
.each do |t|
|
91
|
+
c[t["class"]] ||= IsoDoc::XrefGen::Counter.new
|
92
|
+
j = subfigure_increment(j, c[t["class"]], t)
|
93
|
+
sublabel = j.zero? ? nil : "#{(j + 96).chr})"
|
94
|
+
figure_anchor(t, sublabel, c.print, t["class"])
|
158
95
|
end
|
159
96
|
end
|
160
97
|
|
161
98
|
def hierarchical_figure_names(clause, num)
|
162
99
|
c = IsoDoc::XrefGen::Counter.new
|
163
100
|
j = 0
|
164
|
-
clause.xpath(ns(
|
165
|
-
.each do |t|
|
101
|
+
clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
|
166
102
|
j = subfigure_increment(j, c, t)
|
167
103
|
label = "#{num}#{hiersep}#{c.print}"
|
168
104
|
sublabel = j.zero? ? nil : "#{(j + 96).chr})"
|
169
|
-
|
105
|
+
figure_anchor(t, sublabel, label, "figure")
|
106
|
+
end
|
107
|
+
hierarchical_figure_class_names(clause, num)
|
108
|
+
end
|
170
109
|
|
171
|
-
|
110
|
+
def hierarchical_figure_class_names(clause, num)
|
111
|
+
c = {}
|
112
|
+
j = 0
|
113
|
+
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
114
|
+
.noblank.each do |t|
|
115
|
+
c[t["class"]] ||= IsoDoc::XrefGen::Counter.new
|
116
|
+
j = subfigure_increment(j, c[t["class"]], t)
|
117
|
+
label = "#{num}#{hiersep}#{c.print}"
|
118
|
+
sublabel = j.zero? ? nil : "#{(j + 96).chr})"
|
119
|
+
figure_anchor(t, sublabel, label, t["class"])
|
172
120
|
end
|
173
121
|
end
|
174
122
|
|
@@ -185,10 +133,6 @@ module IsoDoc
|
|
185
133
|
end
|
186
134
|
end
|
187
135
|
|
188
|
-
def annex_name_lbl(clause, num)
|
189
|
-
super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
|
190
|
-
end
|
191
|
-
|
192
136
|
def list_anchor_names(sections)
|
193
137
|
sections.each do |s|
|
194
138
|
notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Iso
|
3
|
+
class Xref < IsoDoc::Xref
|
4
|
+
# we can reference 0-number clauses in introduction
|
5
|
+
def introduction_names(clause)
|
6
|
+
return if clause.nil?
|
7
|
+
|
8
|
+
clause.at(ns("./clause")) and
|
9
|
+
@anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
|
10
|
+
xref: clause.at(ns("./title"))&.text }
|
11
|
+
i = Counter.new
|
12
|
+
clause.xpath(ns("./clause")).each do |c|
|
13
|
+
i.increment(c)
|
14
|
+
section_names1(c, "0.#{i.print}", 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def annex_names(clause, num)
|
19
|
+
appendix_names(clause, num)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def appendix_names(clause, _num)
|
24
|
+
i = Counter.new
|
25
|
+
clause.xpath(ns("./appendix")).each do |c|
|
26
|
+
i.increment(c)
|
27
|
+
@anchors[c["id"]] =
|
28
|
+
anchor_struct(i.print, nil, @labels["appendix"],
|
29
|
+
"clause").merge(level: 2, subtype: "annex",
|
30
|
+
container: clause["id"])
|
31
|
+
j = Counter.new
|
32
|
+
c.xpath(ns("./clause | ./references")).each do |c1|
|
33
|
+
j.increment(c1)
|
34
|
+
lbl = "#{@labels['appendix']} #{i.print}.#{j.print}"
|
35
|
+
appendix_names1(c1, l10n(lbl), 3, clause["id"])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# subclauses are not prefixed with "Clause"
|
41
|
+
# retaining subtype for the semantics
|
42
|
+
def section_names1(clause, num, level)
|
43
|
+
@anchors[clause["id"]] =
|
44
|
+
{ label: num, level: level, xref: num, subtype: "clause" }
|
45
|
+
i = Counter.new
|
46
|
+
clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
|
47
|
+
"./references"))
|
48
|
+
.each do |c|
|
49
|
+
i.increment(c)
|
50
|
+
section_names1(c, "#{num}.#{i.print}", level + 1)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def annex_names1(clause, num, level)
|
55
|
+
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
56
|
+
subtype: "annex" }
|
57
|
+
i = Counter.new
|
58
|
+
clause.xpath(ns("./clause | ./references")).each do |c|
|
59
|
+
i.increment(c)
|
60
|
+
annex_names1(c, "#{num}.#{i.print}", level + 1)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def appendix_names1(clause, num, level, container)
|
65
|
+
@anchors[clause["id"]] = { label: num, xref: num, level: level,
|
66
|
+
container: container }
|
67
|
+
i = Counter.new
|
68
|
+
clause.xpath(ns("./clause | ./references")).each do |c|
|
69
|
+
i.increment(c)
|
70
|
+
appendix_names1(c, "#{num}.#{i.print}", level + 1, container)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def annex_name_lbl(clause, num)
|
75
|
+
super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -73,8 +73,14 @@
|
|
73
73
|
<text/>
|
74
74
|
</element>
|
75
75
|
</define>
|
76
|
-
<define name="
|
76
|
+
<define name="locale">
|
77
77
|
<a:documentation>ISO-639</a:documentation>
|
78
|
+
<element name="locale">
|
79
|
+
<text/>
|
80
|
+
</element>
|
81
|
+
</define>
|
82
|
+
<define name="script">
|
83
|
+
<a:documentation>ISO-3166</a:documentation>
|
78
84
|
<element name="script">
|
79
85
|
<text/>
|
80
86
|
</element>
|
@@ -93,6 +99,9 @@
|
|
93
99
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
94
100
|
<attribute name="language"/>
|
95
101
|
</optional>
|
102
|
+
<optional>
|
103
|
+
<attribute name="locale"/>
|
104
|
+
</optional>
|
96
105
|
<optional>
|
97
106
|
<attribute name="script"/>
|
98
107
|
</optional>
|
@@ -136,6 +145,9 @@
|
|
136
145
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
137
146
|
<attribute name="language"/>
|
138
147
|
</optional>
|
148
|
+
<optional>
|
149
|
+
<attribute name="locale"/>
|
150
|
+
</optional>
|
139
151
|
<optional>
|
140
152
|
<attribute name="script"/>
|
141
153
|
</optional>
|
@@ -650,6 +662,9 @@
|
|
650
662
|
<zeroOrMore>
|
651
663
|
<ref name="language"/>
|
652
664
|
</zeroOrMore>
|
665
|
+
<zeroOrMore>
|
666
|
+
<ref name="locale"/>
|
667
|
+
</zeroOrMore>
|
653
668
|
<zeroOrMore>
|
654
669
|
<ref name="script"/>
|
655
670
|
</zeroOrMore>
|
@@ -741,6 +756,9 @@
|
|
741
756
|
<zeroOrMore>
|
742
757
|
<ref name="language"/>
|
743
758
|
</zeroOrMore>
|
759
|
+
<zeroOrMore>
|
760
|
+
<ref name="locale"/>
|
761
|
+
</zeroOrMore>
|
744
762
|
<zeroOrMore>
|
745
763
|
<ref name="script"/>
|
746
764
|
</zeroOrMore>
|
@@ -854,6 +872,15 @@
|
|
854
872
|
<optional>
|
855
873
|
<attribute name="type"/>
|
856
874
|
</optional>
|
875
|
+
<optional>
|
876
|
+
<attribute name="language"/>
|
877
|
+
</optional>
|
878
|
+
<optional>
|
879
|
+
<attribute name="locale"/>
|
880
|
+
</optional>
|
881
|
+
<optional>
|
882
|
+
<attribute name="script"/>
|
883
|
+
</optional>
|
857
884
|
<data type="anyURI"/>
|
858
885
|
</define>
|
859
886
|
<define name="DateType">
|
@@ -882,6 +909,7 @@
|
|
882
909
|
<value>vote-started</value>
|
883
910
|
<value>vote-ended</value>
|
884
911
|
<value>announced</value>
|
912
|
+
<value>stable-until</value>
|
885
913
|
</choice>
|
886
914
|
</define>
|
887
915
|
<define name="bdate">
|
@@ -930,6 +958,9 @@
|
|
930
958
|
<optional>
|
931
959
|
<attribute name="language"/>
|
932
960
|
</optional>
|
961
|
+
<optional>
|
962
|
+
<attribute name="locale"/>
|
963
|
+
</optional>
|
933
964
|
<optional>
|
934
965
|
<attribute name="script"/>
|
935
966
|
</optional>
|
@@ -215,11 +215,11 @@ pub = (node.attr("publisher") || "ISO").split(/[;,]/)
|
|
215
215
|
|
216
216
|
def id_stage_abbr1(stage, substage, node, bare)
|
217
217
|
if bare
|
218
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
|
218
|
+
IsoDoc::Iso::Metadata.new("en", "Latn", nil, @i18n)
|
219
219
|
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
220
220
|
substage, nil, nil, doctype(node))
|
221
221
|
else
|
222
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
|
222
|
+
IsoDoc::Iso::Metadata.new("en", "Latn", nil, @i18n)
|
223
223
|
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
224
224
|
substage, node.attr("iteration"),
|
225
225
|
node.attr("draft"), doctype(node))
|
@@ -205,6 +205,15 @@
|
|
205
205
|
<data type="boolean"/>
|
206
206
|
</attribute>
|
207
207
|
</optional>
|
208
|
+
<optional>
|
209
|
+
<attribute name="style">
|
210
|
+
<choice>
|
211
|
+
<value>basic</value>
|
212
|
+
<value>full</value>
|
213
|
+
<value>short</value>
|
214
|
+
</choice>
|
215
|
+
</attribute>
|
216
|
+
</optional>
|
208
217
|
<ref name="XrefBody"/>
|
209
218
|
</element>
|
210
219
|
</define>
|
data/lib/metanorma/iso.rb
CHANGED
@@ -3,16 +3,24 @@ module Metanorma
|
|
3
3
|
class Modspec
|
4
4
|
# Don't want to inherit from Metanorma::Requirements::Modspec
|
5
5
|
class Iso < ::Metanorma::Requirements::Modspec
|
6
|
+
def recommendation_label_xref(elem, label, xrefs, _type)
|
7
|
+
id = @reqtlabels[label]
|
8
|
+
number = xrefs.anchor(id, :xref_reqt2reqt, false)
|
9
|
+
number.nil? and return type
|
10
|
+
elem.ancestors("requirement, recommendation, permission").empty? and
|
11
|
+
return number
|
12
|
+
"<xref target='#{id}'>#{number}</xref>"
|
13
|
+
end
|
14
|
+
|
6
15
|
def recommendation_label(elem, type, xrefs)
|
7
16
|
lbl = super
|
8
17
|
title = elem.at(ns("./title"))
|
9
|
-
return lbl unless title
|
18
|
+
return lbl unless title &&
|
19
|
+
elem.ancestors("requirement, recommendation, permission").empty?
|
10
20
|
|
11
|
-
|
12
|
-
|
13
|
-
lbl += l10n(": ") if lbl
|
21
|
+
lbl += ": " if lbl
|
14
22
|
lbl += title.children.to_xml
|
15
|
-
lbl
|
23
|
+
l10n(lbl)
|
16
24
|
end
|
17
25
|
|
18
26
|
# ISO labels modspec reqt as table, with reqt label as title
|
@@ -30,7 +38,8 @@ module Metanorma
|
|
30
38
|
def requirement_component_parse(node, out)
|
31
39
|
if node["exclude"] != "true" && node.name == "description"
|
32
40
|
lbl = "statement"
|
33
|
-
|
41
|
+
recommend_class(node.parent) == "recommendclass" and
|
42
|
+
lbl = "description"
|
34
43
|
out << "<tr><td>#{@labels['modspec'][lbl]}</td>"\
|
35
44
|
"<td>#{node.children.to_xml}</td></tr>"
|
36
45
|
else
|
@@ -38,11 +47,13 @@ module Metanorma
|
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
41
|
-
def requirement_table_cleanup(table)
|
50
|
+
def requirement_table_cleanup(node, table)
|
42
51
|
return table unless table["type"] == "recommendclass"
|
43
52
|
|
53
|
+
label = if node["type"] == "conformanceclass" then "conformancetests"
|
54
|
+
else "provisions" end
|
44
55
|
ins = table.at(ns("./tbody/tr[td/table]")) or return table
|
45
|
-
ins.replace("<tr><td>#{@labels['modspec'][
|
56
|
+
ins.replace("<tr><td>#{@labels['modspec'][label]}</td>" +
|
46
57
|
"<td>#{nested_tables_names(table)}</td></tr>")
|
47
58
|
table.xpath(ns("./tbody/tr[td/table]")).each(&:remove)
|
48
59
|
table
|
@@ -54,6 +65,61 @@ module Metanorma
|
|
54
65
|
m << t.at(ns("./name")).children.to_xml
|
55
66
|
end.join("<br/>")
|
56
67
|
end
|
68
|
+
|
69
|
+
def postprocess_anchor_struct(block, anchor)
|
70
|
+
super
|
71
|
+
anchor[:xref_reqt2reqt] = anchor[:xref_bare]
|
72
|
+
if l = block.at(ns("./title"))
|
73
|
+
anchor[:xref_reqt2reqt] =
|
74
|
+
l10n("#{anchor[:xref_reqt2reqt]}: #{l.children.to_xml.strip}")
|
75
|
+
end
|
76
|
+
anchor
|
77
|
+
end
|
78
|
+
|
79
|
+
def reqt_ids(docxml)
|
80
|
+
docxml.xpath(ns("//requirement | //recommendation | //permission"))
|
81
|
+
.each_with_object({}) do |r, m|
|
82
|
+
id = r.at(ns("./identifier")) or next
|
83
|
+
m[id.text] =
|
84
|
+
{ id: r["id"],
|
85
|
+
lbl: @xrefs.anchor(r["id"], :xref_reqt2reqt, false) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def reqt_links_test(docxml)
|
90
|
+
docxml.xpath(ns("//requirement | //recommendation | //permission"))
|
91
|
+
.each_with_object({}) do |r, m|
|
92
|
+
next unless %w(conformanceclass
|
93
|
+
verification).include?(r["type"])
|
94
|
+
|
95
|
+
subj = r.at(ns("./classification[tag = 'target']/value"))
|
96
|
+
id = r.at(ns("./identifier")) or next
|
97
|
+
lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt,
|
98
|
+
false)
|
99
|
+
next unless subj
|
100
|
+
|
101
|
+
m[subj.text] = { lbl: lbl, id: r["id"] }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def reqt_links_class(docxml)
|
106
|
+
docxml.xpath(ns("//requirement | //recommendation | //permission"))
|
107
|
+
.each_with_object({}) do |r, m|
|
108
|
+
next unless %w(class
|
109
|
+
conformanceclass).include?(r["type"])
|
110
|
+
|
111
|
+
id = r.at(ns("./identifier")) or next
|
112
|
+
r.xpath(ns("./requirement | ./recommendation | ./permission"))
|
113
|
+
.each do |r1|
|
114
|
+
id1 = r1.at(ns("./identifier")) or next
|
115
|
+
lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id],
|
116
|
+
:xref_reqt2reqt, false)
|
117
|
+
next unless lbl
|
118
|
+
|
119
|
+
m[id1.text] = { lbl: lbl, id: r["id"] }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
57
123
|
end
|
58
124
|
end
|
59
125
|
end
|
data/lib/metanorma-iso.rb
CHANGED
@@ -10,6 +10,7 @@ require_relative "isodoc/iso/isosts_convert"
|
|
10
10
|
require_relative "isodoc/iso/presentation_xml_convert"
|
11
11
|
require_relative "html2doc/lists"
|
12
12
|
require "asciidoctor/extensions"
|
13
|
+
require "metanorma"
|
13
14
|
|
14
15
|
if defined? Metanorma::Registry
|
15
16
|
require_relative "metanorma/iso"
|
@@ -1,4 +1,56 @@
|
|
1
|
+
extenttemplate:
|
2
|
+
book: "{{ volume }} {{ page }}"
|
3
|
+
booklet: book
|
4
|
+
proceedings: book
|
5
|
+
journal: book
|
6
|
+
standard: book
|
7
|
+
techreport: book
|
8
|
+
inbook: "{{ volume }} {{ page }}"
|
9
|
+
misc: "{{ volume }} {{issue}} {{ page }}, {{ duration }}"
|
10
|
+
nametemplate:
|
11
|
+
one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0]}} {{initials[0] | join: ''}}.{% endif %}"
|
12
|
+
two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0]}} {{initials[0] | join: ''}}.{% endif %} , & {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{initials[1] | join: ''}}.{% endif %}"
|
13
|
+
more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0]}} {{initials[0] | join: ''}}.{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{initials[1] | join: ''}}. {% endif %} , & {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2]}} {{initials[2] | join: ''}}.{% endif %}"
|
14
|
+
# disabled the following: they should be provided in inheriting calls
|
15
|
+
# etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{%if given[1]%}{{given[1]}} {{middle[1]}}{%else%}{{initials[1] | join: ' '}}.{%endif%} {{surname[1] | upcase}}{% endif %} <em>et al.</em>"
|
16
|
+
# etal_count: 5
|
17
|
+
seriestemplate: "{% if series_formatted %}{{ series_formatted }}{%else%}{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ({{series_run}}) {{series_num}}|({{series_partnumber}}){%endif%}"
|
18
|
+
journaltemplate: "<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> ({{series_run}}) {{ labels['volume'] }}_{{series_num}} {{ labels['part'] }}_{{series_partnumber}}"
|
1
19
|
template:
|
2
20
|
# skip standardidentifier, it is inserted in front of formattedref within metanorma
|
3
21
|
standard: "<em><span_class='stddocTitle'>{{ title }}</span></em> ,_{{ extent }}."
|
4
|
-
website: "{{ creatornames }} ({{ role }}) . <em><span_class='stddocTitle'>{{ title }}</span></em> [website]. {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{
|
22
|
+
website: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em><span_class='stddocTitle'>{{ title }}</span></em> [website]. {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{place}}: {{ publisher }}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
|
23
|
+
book: "<smallcap>{{ creatornames }}</smallcap> ({{role}}) . <em>{{ title }}</em> . {{ edition | capitalize_first }}. ({{ series }}). {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
24
|
+
booklet: book
|
25
|
+
manual: book
|
26
|
+
proceedings: book
|
27
|
+
inbook: "<smallcap>{{ creatornames }}</smallcap> ({{role}}) . {{ title }} . <em>{{host_title}}</em> ({{host_role}} {{ host_creatornames}}). {{ edition | capitalize_first }}. ({{ series }}). {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
28
|
+
inproceedings: inbook
|
29
|
+
incollection: inbook
|
30
|
+
journal: "<em>{{ title}}</em> . {{ edition | capitalize_first }}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
31
|
+
article: "<smallcap>{{ creatornames }}</smallcap> ({{role}}) . {{ title }}. {{ series }} . {{date}}, {{ extent }}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
32
|
+
software: "<smallcap>{{ creatornames }}</smallcap> ({{ role}}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize}}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
|
33
|
+
electronic resource: software
|
34
|
+
dataset: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ labels['in'] | capitalize }}:_{{series}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join '. ' }}. {{ other_identifier | join '. ' }}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ size }}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
|
35
|
+
webresource: website
|
36
|
+
unpublished: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
37
|
+
presentation: unpublished
|
38
|
+
thesis: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{place}}: {{ publisher }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]."
|
39
|
+
misc: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ date }}."
|
40
|
+
# following are # unsupported types:
|
41
|
+
map: misc
|
42
|
+
audiovisual: misc
|
43
|
+
film: misc
|
44
|
+
video: misc
|
45
|
+
broadcast: misc
|
46
|
+
graphic_work: misc
|
47
|
+
music: misc
|
48
|
+
performance: misc
|
49
|
+
patent: misc
|
50
|
+
archival: misc
|
51
|
+
social_media: misc
|
52
|
+
alert: misc
|
53
|
+
message: misc
|
54
|
+
conversation: misc
|
55
|
+
internal: misc
|
56
|
+
|
data/metanorma-iso.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
31
31
|
|
32
|
-
spec.add_dependency "metanorma-standoc", "~> 2.2.
|
32
|
+
spec.add_dependency "metanorma-standoc", "~> 2.2.4"
|
33
33
|
spec.add_dependency "mnconvert", "~> 1.14"
|
34
34
|
spec.add_dependency "pubid-iso"
|
35
35
|
spec.add_dependency "ruby-jing"
|
data/spec/isodoc/i18n_spec.rb
CHANGED
@@ -1332,7 +1332,7 @@ RSpec.describe IsoDoc do
|
|
1332
1332
|
<clause id="D" obligation="normative" type="scope" displayorder='3'>
|
1333
1333
|
<title depth="1">1<tab/>Scope</title>
|
1334
1334
|
<p id="E">
|
1335
|
-
<eref bibitemid="ISO712" type="inline"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712
|
1335
|
+
<eref bibitemid="ISO712" type="inline"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712, <span class='citetbl'>第1–1表</span></eref>
|
1336
1336
|
</p>
|
1337
1337
|
</clause>
|
1338
1338
|
<clause id="H" obligation="normative" displayorder='5'>
|
@@ -1423,7 +1423,7 @@ RSpec.describe IsoDoc do
|
|
1423
1423
|
<div id='D'>
|
1424
1424
|
<h1>1 Scope</h1>
|
1425
1425
|
<p id='E'>
|
1426
|
-
<a href='#ISO712'>ISO 712
|
1426
|
+
<a href='#ISO712'>ISO 712, 第1–1表</a>
|
1427
1427
|
</p>
|
1428
1428
|
</div>
|
1429
1429
|
<div>
|