metanorma-iso 1.8.1 → 1.8.2
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/.rubocop.yml +0 -2
- data/lib/asciidoctor/iso/base.rb +1 -0
- data/lib/asciidoctor/iso/cleanup.rb +17 -5
- data/lib/asciidoctor/iso/front.rb +3 -1
- data/lib/asciidoctor/iso/front_id.rb +66 -50
- data/lib/asciidoctor/iso/isodoc.rng +174 -0
- data/lib/asciidoctor/iso/isostandard.rng +1 -0
- data/lib/asciidoctor/iso/section.rb +2 -1
- data/lib/isodoc/iso/iso.amendment.xsl +65 -0
- data/lib/isodoc/iso/iso.international-standard.xsl +65 -0
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/sts_convert.rb +10 -13
- data/lib/isodoc/iso/xref.rb +31 -18
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +1 -1
- data/spec/asciidoctor/base_spec.rb +426 -334
- data/spec/asciidoctor/cleanup_spec.rb +383 -25
- data/spec/asciidoctor/section_spec.rb +0 -14
- data/spec/asciidoctor/validate_spec.rb +72 -39
- data/spec/isodoc/postproc_spec.rb +475 -434
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35b59081db707249f715188c97e36d12b87d07bb80ce85d34246828a5ab1bec3
|
4
|
+
data.tar.gz: 7c815a0b3bdaea0f9592068920aab0ce50fa60ded38e1b4ed8e35b0d2f15b35c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79dfb38b8dde27b13ea207d8c7eb12f5395a4adf73a1b254bc179b8bff51bffe169885454aaff18ddd20e378f0e6e336869964293f7503f375892c91028403d0
|
7
|
+
data.tar.gz: b22f9abeb337fd65d613e8cf6c6b76397c24de3cb9b27c4bca447f76e2c712130cde51034ed8cfbd7d7863bd4961170dfdf279ab18ecc366ba7d1887aa22b746
|
data/.rubocop.yml
CHANGED
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -65,8 +65,12 @@ module Asciidoctor
|
|
65
65
|
super
|
66
66
|
end
|
67
67
|
|
68
|
-
TERM_CLAUSE = "//sections//terms"
|
68
|
+
TERM_CLAUSE = "//sections//terms | "\
|
69
|
+
"//sections//clause[descendant::terms][not(descendant::definitions)]"
|
70
|
+
.freeze
|
71
|
+
|
69
72
|
PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
|
73
|
+
|
70
74
|
OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
|
71
75
|
"@type = 'ISBN'".freeze
|
72
76
|
|
@@ -154,12 +158,20 @@ module Asciidoctor
|
|
154
158
|
|
155
159
|
id = b.at("docidentifier").text
|
156
160
|
b.at("./language | ./script | ./abstract | ./status")
|
157
|
-
.previous =
|
158
|
-
|
159
|
-
<p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>
|
160
|
-
NOTE
|
161
|
+
.previous = %(<note type="Unpublished-Status">
|
162
|
+
<p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>)
|
161
163
|
end
|
162
164
|
end
|
165
|
+
|
166
|
+
def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
|
167
|
+
once = true
|
168
|
+
super
|
169
|
+
end
|
170
|
+
|
171
|
+
def term_defs_boilerplate_cont(src, term, isodoc)
|
172
|
+
@vocab and src.empty? and return
|
173
|
+
super
|
174
|
+
end
|
163
175
|
end
|
164
176
|
end
|
165
177
|
end
|
@@ -115,7 +115,9 @@ module Asciidoctor
|
|
115
115
|
return unless node.attr("title-amendment-#{lang}")
|
116
116
|
|
117
117
|
xml.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
|
118
|
-
t1 << Metanorma::Utils::asciidoc_sub(
|
118
|
+
t1 << Metanorma::Utils::asciidoc_sub(
|
119
|
+
node.attr("title-amendment-#{lang}")
|
120
|
+
)
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
@@ -35,22 +35,26 @@ module Asciidoctor
|
|
35
35
|
|
36
36
|
def stage_abbr(stage, substage, doctype)
|
37
37
|
return nil if stage.to_i > 60
|
38
|
+
|
38
39
|
ret = STAGE_ABBRS[stage.to_sym]
|
39
40
|
ret = "PRF" if stage == "60" && substage == "00"
|
40
41
|
ret = "AWI" if stage == "10" && substage == "99"
|
41
|
-
if %w(amendment technical-corrigendum technical-report
|
42
|
-
|
42
|
+
if %w(amendment technical-corrigendum technical-report
|
43
|
+
technical-specification).include?(doctype)
|
43
44
|
ret = "D" if stage == "40" && doctype == "amendment"
|
44
|
-
ret = "FD" if stage == "50" && %w(amendment technical-corrigendum)
|
45
|
+
ret = "FD" if stage == "50" && %w(amendment technical-corrigendum)
|
46
|
+
.include?(doctype)
|
45
47
|
end
|
46
48
|
ret
|
47
49
|
end
|
48
50
|
|
49
51
|
def stage_name(stage, substage, doctype, iteration = nil)
|
50
52
|
return "Proof" if stage == "60" && substage == "00"
|
53
|
+
|
51
54
|
ret = STAGE_NAMES[stage.to_sym]
|
52
55
|
if iteration && %w(20 30).include?(stage)
|
53
|
-
prefix = iteration.to_i.localize(@lang.to_sym)
|
56
|
+
prefix = iteration.to_i.localize(@lang.to_sym)
|
57
|
+
.to_rbnf_s("SpelloutRules", "spellout-ordinal")
|
54
58
|
ret = "#{prefix.capitalize} #{ret.downcase}"
|
55
59
|
end
|
56
60
|
ret
|
@@ -65,37 +69,39 @@ module Asciidoctor
|
|
65
69
|
end
|
66
70
|
|
67
71
|
def iso_id(node, xml)
|
68
|
-
|
72
|
+
!@amd && node.attr("docnumber") || @amd && node.attr("updates") or
|
73
|
+
return
|
74
|
+
|
69
75
|
dn = iso_id1(node)
|
70
76
|
dn1 = id_stage_prefix(dn, node, false)
|
71
77
|
dn2 = id_stage_prefix(dn, node, true)
|
72
78
|
xml.docidentifier dn1, **attr_code(type: "ISO")
|
73
|
-
xml.docidentifier
|
74
|
-
|
79
|
+
xml.docidentifier(id_langsuffix(dn1, node),
|
80
|
+
**attr_code(type: "iso-with-lang"))
|
81
|
+
xml.docidentifier(id_langsuffix(dn2, node),
|
82
|
+
**attr_code(type: "iso-reference"))
|
75
83
|
end
|
76
84
|
|
77
85
|
def iso_id1(node)
|
78
86
|
if @amd
|
79
87
|
dn = node.attr("updates")
|
80
|
-
|
88
|
+
add_amd_parts(dn, node)
|
81
89
|
else
|
82
90
|
part, subpart = node&.attr("partnumber")&.split(/-/)
|
83
|
-
|
91
|
+
add_id_parts(node.attr("docnumber"), part, subpart)
|
84
92
|
end
|
85
93
|
end
|
86
94
|
|
87
|
-
def add_amd_parts(
|
88
|
-
a = node.attr("amendment-number")
|
89
|
-
c = node.attr("corrigendum-number")
|
95
|
+
def add_amd_parts(docnum, node)
|
90
96
|
case doctype(node)
|
91
97
|
when "amendment"
|
92
|
-
"#{
|
98
|
+
"#{docnum}/Amd #{node.attr('amendment-number')}"
|
93
99
|
when "technical-corrigendum"
|
94
|
-
"#{
|
100
|
+
"#{docnum}/Cor.#{node.attr('corrigendum-number')}"
|
95
101
|
end
|
96
102
|
end
|
97
103
|
|
98
|
-
def id_langsuffix(
|
104
|
+
def id_langsuffix(docnum, node)
|
99
105
|
lang = node.attr("language") || "en"
|
100
106
|
suffix = case lang
|
101
107
|
when "en" then "(E)"
|
@@ -103,38 +109,43 @@ module Asciidoctor
|
|
103
109
|
else
|
104
110
|
"(X)"
|
105
111
|
end
|
106
|
-
"#{
|
112
|
+
"#{docnum}#{suffix}"
|
107
113
|
end
|
108
114
|
|
109
115
|
def structured_id(node, xml)
|
110
116
|
return unless node.attr("docnumber")
|
117
|
+
|
111
118
|
part, subpart = node&.attr("partnumber")&.split(/-/)
|
112
119
|
xml.structuredidentifier do |i|
|
113
|
-
i.project_number
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
120
|
+
i.project_number(node.attr("docnumber"), **attr_code(
|
121
|
+
part: part, subpart: subpart,
|
122
|
+
amendment: node.attr("amendment-number"),
|
123
|
+
corrigendum: node.attr("corrigendum-number"),
|
124
|
+
origyr: node.attr("created-date")
|
125
|
+
))
|
118
126
|
end
|
119
127
|
end
|
120
128
|
|
121
|
-
def add_id_parts(
|
122
|
-
|
123
|
-
|
124
|
-
|
129
|
+
def add_id_parts(docnum, part, subpart)
|
130
|
+
docnum += "-#{part}" if part
|
131
|
+
docnum += "-#{subpart}" if subpart
|
132
|
+
docnum
|
125
133
|
end
|
126
134
|
|
127
135
|
def id_stage_abbr(stage, substage, node, bare = false)
|
128
|
-
ret = bare
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
ret = if bare
|
137
|
+
IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
|
138
|
+
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
139
|
+
substage, nil, nil, doctype(node))
|
140
|
+
else
|
141
|
+
IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
|
142
|
+
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
143
|
+
substage, node.attr("iteration"),
|
144
|
+
node.attr("draft"), doctype(node))
|
145
|
+
end
|
146
|
+
if %w(amendment technical-corrigendum technical-report
|
147
|
+
technical-specification).include?(doctype(node))
|
148
|
+
ret = "#{ret} " unless %w(D FD).include?(ret)
|
138
149
|
end
|
139
150
|
ret
|
140
151
|
end
|
@@ -143,51 +154,56 @@ module Asciidoctor
|
|
143
154
|
stage = get_stage(node)
|
144
155
|
abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
|
145
156
|
typeabbr = get_typeabbr(node, true)
|
146
|
-
|
157
|
+
if stage.to_i > 50 || stage.to_i == 60 && get_substage(node).to_i < 60
|
158
|
+
typeabbr = ""
|
159
|
+
end
|
147
160
|
"#{abbr}#{typeabbr}".strip
|
148
161
|
end
|
149
162
|
|
150
|
-
def id_stage_prefix(
|
163
|
+
def id_stage_prefix(docnum, node, force_year)
|
151
164
|
stage = get_stage(node)
|
152
165
|
typeabbr = get_typeabbr(node)
|
153
166
|
if stage && (stage.to_i < 60)
|
154
|
-
|
155
|
-
elsif typeabbr
|
167
|
+
docnum = unpub_stage_prefix(docnum, stage, typeabbr, node)
|
168
|
+
elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
|
169
|
+
elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
|
156
170
|
end
|
157
171
|
(force_year || !(stage && (stage.to_i < 60))) and
|
158
|
-
|
159
|
-
|
172
|
+
docnum = id_add_year(docnum, node)
|
173
|
+
docnum
|
160
174
|
end
|
161
175
|
|
162
|
-
def unpub_stage_prefix(
|
176
|
+
def unpub_stage_prefix(docnum, stage, typeabbr, node)
|
163
177
|
abbr = id_stage_abbr(stage, get_substage(node), node)
|
164
178
|
%w(40 50).include?(stage) && i = node.attr("iteration") and
|
165
179
|
itersuffix = ".#{i}"
|
166
|
-
return
|
167
|
-
return "/#{abbr}#{typeabbr} #{
|
168
|
-
|
180
|
+
return docnum if abbr.nil? || abbr.empty? # prefixes added in cleanup
|
181
|
+
return "/#{abbr}#{typeabbr} #{docnum}#{itersuffix}" unless @amd
|
182
|
+
|
183
|
+
a = docnum.split(%r{/})
|
169
184
|
a[-1] = "#{abbr}#{a[-1]}#{itersuffix}"
|
170
185
|
a.join("/")
|
171
186
|
end
|
172
187
|
|
173
|
-
def id_add_year(
|
188
|
+
def id_add_year(docnum, node)
|
174
189
|
year = node.attr("copyright-year")
|
175
190
|
@amd and year ||= node.attr("updated-date")&.sub(/-.*$/, "")
|
176
|
-
|
177
|
-
|
191
|
+
docnum += ":#{year}" if year
|
192
|
+
docnum
|
178
193
|
end
|
179
194
|
|
180
195
|
def get_stage(node)
|
181
|
-
|
196
|
+
node.attr("status") || node.attr("docstage") || "60"
|
182
197
|
end
|
183
198
|
|
184
199
|
def get_substage(node)
|
185
200
|
stage = get_stage(node)
|
186
|
-
node.attr("docsubstage") || (
|
201
|
+
node.attr("docsubstage") || (stage == "60" ? "60" : "00")
|
187
202
|
end
|
188
203
|
|
189
204
|
def get_typeabbr(node, amd = false)
|
190
205
|
case doctype(node)
|
206
|
+
when "directive" then "DIR "
|
191
207
|
when "technical-report" then "TR "
|
192
208
|
when "technical-specification" then "TS "
|
193
209
|
when "amendment" then (amd ? "Amd " : "")
|
@@ -876,6 +876,18 @@
|
|
876
876
|
</zeroOrMore>
|
877
877
|
</element>
|
878
878
|
</define>
|
879
|
+
<define name="pagebreak">
|
880
|
+
<element name="pagebreak">
|
881
|
+
<optional>
|
882
|
+
<attribute name="orientation">
|
883
|
+
<choice>
|
884
|
+
<value>landscape</value>
|
885
|
+
<value>portrait</value>
|
886
|
+
</choice>
|
887
|
+
</attribute>
|
888
|
+
</optional>
|
889
|
+
</element>
|
890
|
+
</define>
|
879
891
|
</include>
|
880
892
|
<!-- end overrides -->
|
881
893
|
<define name="colgroup">
|
@@ -943,8 +955,170 @@
|
|
943
955
|
<ref name="permission"/>
|
944
956
|
<ref name="imagemap"/>
|
945
957
|
<ref name="svgmap"/>
|
958
|
+
<ref name="inputform"/>
|
959
|
+
</choice>
|
960
|
+
</define>
|
961
|
+
<define name="inputform">
|
962
|
+
<element name="form">
|
963
|
+
<attribute name="id">
|
964
|
+
<data type="ID"/>
|
965
|
+
</attribute>
|
966
|
+
<attribute name="name"/>
|
967
|
+
<attribute name="action"/>
|
968
|
+
<zeroOrMore>
|
969
|
+
<choice>
|
970
|
+
<ref name="TextElement"/>
|
971
|
+
<ref name="FormInput"/>
|
972
|
+
</choice>
|
973
|
+
</zeroOrMore>
|
974
|
+
</element>
|
975
|
+
</define>
|
976
|
+
<define name="FormInput">
|
977
|
+
<choice>
|
978
|
+
<ref name="input"/>
|
979
|
+
<ref name="formlabel"/>
|
980
|
+
<ref name="select"/>
|
981
|
+
<ref name="textarea"/>
|
982
|
+
</choice>
|
983
|
+
</define>
|
984
|
+
<define name="InputType">
|
985
|
+
<choice>
|
986
|
+
<value>button</value>
|
987
|
+
<value>checkbox</value>
|
988
|
+
<value>date</value>
|
989
|
+
<value>file</value>
|
990
|
+
<value>password</value>
|
991
|
+
<value>radio</value>
|
992
|
+
<value>submit</value>
|
993
|
+
<value>text</value>
|
946
994
|
</choice>
|
947
995
|
</define>
|
996
|
+
<define name="input">
|
997
|
+
<element name="input">
|
998
|
+
<attribute name="type">
|
999
|
+
<ref name="InputType"/>
|
1000
|
+
</attribute>
|
1001
|
+
<optional>
|
1002
|
+
<attribute name="checked">
|
1003
|
+
<data type="boolean"/>
|
1004
|
+
</attribute>
|
1005
|
+
</optional>
|
1006
|
+
<optional>
|
1007
|
+
<attribute name="disabled">
|
1008
|
+
<data type="boolean"/>
|
1009
|
+
</attribute>
|
1010
|
+
</optional>
|
1011
|
+
<optional>
|
1012
|
+
<attribute name="readonly">
|
1013
|
+
<data type="boolean"/>
|
1014
|
+
</attribute>
|
1015
|
+
</optional>
|
1016
|
+
<optional>
|
1017
|
+
<attribute name="maxlength">
|
1018
|
+
<data type="int"/>
|
1019
|
+
</attribute>
|
1020
|
+
</optional>
|
1021
|
+
<optional>
|
1022
|
+
<attribute name="minlength">
|
1023
|
+
<data type="int"/>
|
1024
|
+
</attribute>
|
1025
|
+
</optional>
|
1026
|
+
<optional>
|
1027
|
+
<attribute name="name"/>
|
1028
|
+
</optional>
|
1029
|
+
<optional>
|
1030
|
+
<attribute name="value"/>
|
1031
|
+
</optional>
|
1032
|
+
<optional>
|
1033
|
+
<attribute name="id">
|
1034
|
+
<data type="ID"/>
|
1035
|
+
</attribute>
|
1036
|
+
</optional>
|
1037
|
+
</element>
|
1038
|
+
</define>
|
1039
|
+
<define name="formlabel">
|
1040
|
+
<element name="label">
|
1041
|
+
<attribute name="for">
|
1042
|
+
<data type="IDREF"/>
|
1043
|
+
</attribute>
|
1044
|
+
<zeroOrMore>
|
1045
|
+
<ref name="PureTextElement"/>
|
1046
|
+
</zeroOrMore>
|
1047
|
+
</element>
|
1048
|
+
</define>
|
1049
|
+
<define name="select">
|
1050
|
+
<element name="select">
|
1051
|
+
<optional>
|
1052
|
+
<attribute name="name"/>
|
1053
|
+
</optional>
|
1054
|
+
<optional>
|
1055
|
+
<attribute name="value"/>
|
1056
|
+
</optional>
|
1057
|
+
<optional>
|
1058
|
+
<attribute name="id">
|
1059
|
+
<data type="ID"/>
|
1060
|
+
</attribute>
|
1061
|
+
</optional>
|
1062
|
+
<optional>
|
1063
|
+
<attribute name="disabled">
|
1064
|
+
<data type="boolean"/>
|
1065
|
+
</attribute>
|
1066
|
+
</optional>
|
1067
|
+
<optional>
|
1068
|
+
<attribute name="multiple">
|
1069
|
+
<data type="boolean"/>
|
1070
|
+
</attribute>
|
1071
|
+
</optional>
|
1072
|
+
<optional>
|
1073
|
+
<attribute name="size">
|
1074
|
+
<data type="int"/>
|
1075
|
+
</attribute>
|
1076
|
+
</optional>
|
1077
|
+
<oneOrMore>
|
1078
|
+
<ref name="option"/>
|
1079
|
+
</oneOrMore>
|
1080
|
+
</element>
|
1081
|
+
</define>
|
1082
|
+
<define name="option">
|
1083
|
+
<element name="option">
|
1084
|
+
<optional>
|
1085
|
+
<attribute name="disabled">
|
1086
|
+
<data type="boolean"/>
|
1087
|
+
</attribute>
|
1088
|
+
</optional>
|
1089
|
+
<optional>
|
1090
|
+
<attribute name="value"/>
|
1091
|
+
</optional>
|
1092
|
+
<zeroOrMore>
|
1093
|
+
<ref name="PureTextElement"/>
|
1094
|
+
</zeroOrMore>
|
1095
|
+
</element>
|
1096
|
+
</define>
|
1097
|
+
<define name="textarea">
|
1098
|
+
<element name="textarea">
|
1099
|
+
<optional>
|
1100
|
+
<attribute name="name"/>
|
1101
|
+
</optional>
|
1102
|
+
<optional>
|
1103
|
+
<attribute name="value"/>
|
1104
|
+
</optional>
|
1105
|
+
<optional>
|
1106
|
+
<attribute name="id">
|
1107
|
+
<data type="ID"/>
|
1108
|
+
</attribute>
|
1109
|
+
</optional>
|
1110
|
+
<optional>
|
1111
|
+
<attribute name="rows">
|
1112
|
+
<data type="int"/>
|
1113
|
+
</attribute>
|
1114
|
+
</optional>
|
1115
|
+
<optional>
|
1116
|
+
<attribute name="cols">
|
1117
|
+
<data type="int"/>
|
1118
|
+
</attribute>
|
1119
|
+
</optional>
|
1120
|
+
</element>
|
1121
|
+
</define>
|
948
1122
|
<define name="bibliography">
|
949
1123
|
<element name="bibliography">
|
950
1124
|
<oneOrMore>
|