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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d170797212efc1050755714c1c875246a5b1b07ca8c4c1b6562b51ab2ee44a9
4
- data.tar.gz: a6deb053bf737183c275a1f93a110d89f8fa42a093bafd514c7d672b5e16f427
3
+ metadata.gz: 35b59081db707249f715188c97e36d12b87d07bb80ce85d34246828a5ab1bec3
4
+ data.tar.gz: 7c815a0b3bdaea0f9592068920aab0ce50fa60ded38e1b4ed8e35b0d2f15b35c
5
5
  SHA512:
6
- metadata.gz: 63752e6b4a75cba612fca7cacf5c0ccd7a4553f51b9743e667d7a2891737dff68deace61efcab395be2f22e8b4d6559ee8eee6c50ad84e3f13e627af1ca98a68
7
- data.tar.gz: 401f42f155a7424266d3bf62cb6fca9a67ad1adeddf01145c55de95397a91de22847b56fa92563d64045eb6dc2682511eab3925d60f74b1ca737f8ecefacee63
6
+ metadata.gz: 79dfb38b8dde27b13ea207d8c7eb12f5395a4adf73a1b254bc179b8bff51bffe169885454aaff18ddd20e378f0e6e336869964293f7503f375892c91028403d0
7
+ data.tar.gz: b22f9abeb337fd65d613e8cf6c6b76397c24de3cb9b27c4bca447f76e2c712130cde51034ed8cfbd7d7863bd4961170dfdf279ab18ecc366ba7d1887aa22b746
data/.rubocop.yml CHANGED
@@ -10,5 +10,3 @@ AllCops:
10
10
  DisplayCopNames: false
11
11
  StyleGuideCopsOnly: false
12
12
  TargetRubyVersion: 2.4
13
- Rails:
14
- Enabled: true
@@ -44,6 +44,7 @@ module Asciidoctor
44
44
  def init(node)
45
45
  super
46
46
  @amd = %w(amendment technical-corrigendum).include? doctype(node)
47
+ @vocab = node.attr("docsubtype") == "vocabulary"
47
48
  end
48
49
 
49
50
  def ol_attrs(node)
@@ -65,8 +65,12 @@ module Asciidoctor
65
65
  super
66
66
  end
67
67
 
68
- TERM_CLAUSE = "//sections//terms".freeze
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 = <<~NOTE
158
- <note type="Unpublished-Status">
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(node.attr("title-amendment-#{lang}"))
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
- technical-specification).include?(doctype)
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).include?(doctype)
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).to_rbnf_s("SpelloutRules", "spellout-ordinal")
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
- return unless !@amd && node.attr("docnumber") || @amd && node.attr("updates")
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 id_langsuffix(dn1, node), **attr_code(type: "iso-with-lang")
74
- xml.docidentifier id_langsuffix(dn2, node), **attr_code(type: "iso-reference")
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
- return add_amd_parts(dn, node)
88
+ add_amd_parts(dn, node)
81
89
  else
82
90
  part, subpart = node&.attr("partnumber")&.split(/-/)
83
- return add_id_parts(node.attr("docnumber"), part, subpart)
91
+ add_id_parts(node.attr("docnumber"), part, subpart)
84
92
  end
85
93
  end
86
94
 
87
- def add_amd_parts(dn, node)
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
- "#{dn}/Amd #{node.attr('amendment-number')}"
98
+ "#{docnum}/Amd #{node.attr('amendment-number')}"
93
99
  when "technical-corrigendum"
94
- "#{dn}/Cor.#{node.attr('corrigendum-number')}"
100
+ "#{docnum}/Cor.#{node.attr('corrigendum-number')}"
95
101
  end
96
102
  end
97
103
 
98
- def id_langsuffix(dn, node)
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
- "#{dn}#{suffix}"
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 node.attr("docnumber"),
114
- **attr_code(part: part, subpart: subpart,
115
- amendment: node.attr("amendment-number"),
116
- corrigendum: node.attr("corrigendum-number"),
117
- origyr: node.attr("created-date"))
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(dn, part, subpart)
122
- dn += "-#{part}" if part
123
- dn += "-#{subpart}" if subpart
124
- dn
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
- IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
130
- .status_abbrev(stage_abbr(stage, substage, doctype(node)),
131
- substage, nil, nil, doctype(node)) :
132
- IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
133
- .status_abbrev(stage_abbr(stage, substage, doctype(node)),
134
- substage, node.attr("iteration"),
135
- node.attr("draft"), doctype(node))
136
- if %w(amendment technical-corrigendum technical-report technical-specification).include?(doctype(node))
137
- ret = ret + " " unless %w(D FD).include?(ret)
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
- typeabbr = "" if stage.to_i > 50 || stage.to_i == 60 && get_substage(node).to_i < 60
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(dn, node, force_year)
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
- dn = unpub_stage_prefix(dn, stage, typeabbr, node)
155
- elsif typeabbr && !@amd then dn = "/#{typeabbr}#{dn}"
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
- dn = id_add_year(dn, node)
159
- dn
172
+ docnum = id_add_year(docnum, node)
173
+ docnum
160
174
  end
161
175
 
162
- def unpub_stage_prefix(dn, stage, typeabbr, node)
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 dn if abbr.nil? || abbr.empty? # prefixes added in cleanup
167
- return "/#{abbr}#{typeabbr} #{dn}#{itersuffix}" unless @amd
168
- a = dn.split(%r{/})
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(dn, node)
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
- dn += ":#{year}" if year
177
- dn
191
+ docnum += ":#{year}" if year
192
+ docnum
178
193
  end
179
194
 
180
195
  def get_stage(node)
181
- stage = node.attr("status") || node.attr("docstage") || "60"
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") || ( stage == "60" ? "60" : "00" )
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>