metanorma-itu 1.3.7 → 1.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ca33e71c52b4abfd8da601d6a7138fee1b2f9f8635fd6c2f59873dbdce25874
4
- data.tar.gz: 8300592013092cffc941fa2c391cab8d26186c54ca76534a50009c88a469a9d1
3
+ metadata.gz: ad435d6188b9f2e881c84f0d43a6c35fd2bb4d6c993d1d796b830f755a2d3e33
4
+ data.tar.gz: 95409047e659d65a1c4b0102ebf910d69fe062ab4731511060625ed78ddb362c
5
5
  SHA512:
6
- metadata.gz: ae3b8e20958c4af55882f7042f7501d89a78435262beff085b445879eccc4fcff6124bb56c70761b68d355147ae016d4e2f1d99218e9db54efb5c161ebcc2f19
7
- data.tar.gz: 8beff7d2981d2403465f2304520dea41883ed868947e5ed42b5cc86a844c8be77845dd0ef16bb9ee073f963770db742b6a8d47d67339650dcac60f039d5cea6c
6
+ metadata.gz: 8a3db12e7809503cd242cb1c1f3b6d1b1a579ebbed62fb7ba91c357bdc264b601aefa5e64dee6c0aa2d3cf0a2afd2a01c5e6f43c98343dbc5d0b742aa3472c96
7
+ data.tar.gz: bd64d897084265a9be463d56dcf31dde685b7e36ab56f75016d89d2ad7dc486816e393557c8c84a013e4fd06567c4b8ce4ffcd695d15597ada66b12295f5c006
@@ -1,17 +1,19 @@
1
1
  module Asciidoctor
2
2
  module ITU
3
3
  class Converter < Standoc::Converter
4
- def sections_cleanup(x)
4
+ def sections_cleanup(xml)
5
5
  super
6
- insert_missing_sections(x) unless @no_insert_missing_sections
7
- insert_empty_clauses(x)
8
- resolution_inline_header(x)
6
+ insert_missing_sections(xml) unless @no_insert_missing_sections
7
+ insert_empty_clauses(xml)
8
+ resolution_inline_header(xml)
9
9
  end
10
10
 
11
- def resolution_inline_header(x)
12
- return unless x&.at("//bibdata/ext/doctype")&.text == "resolution"
13
- x.xpath("//clause//clause").each do |c|
14
- next if title = c.at("./title") and !title&.text&.empty?
11
+ def resolution_inline_header(xml)
12
+ return unless xml&.at("//bibdata/ext/doctype")&.text == "resolution"
13
+
14
+ xml.xpath("//clause//clause").each do |c|
15
+ next if (title = c.at("./title")) && !title&.text&.empty?
16
+
15
17
  c["inline-header"] = true
16
18
  end
17
19
  end
@@ -36,67 +38,67 @@ module Asciidoctor
36
38
  %(id="_#{UUIDTools::UUID.random_create}")
37
39
  end
38
40
 
39
- def insert_scope(x)
40
- x.at("./*/sections") or
41
- x.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
42
- "<sections><sentinel/></sections>"
43
- x.at("./*/sections/*") or x.at("./*/sections") << "<sentinel/>"
44
- ins = x.at("//sections").elements.first
45
- x.at("//sections/clause[@type = 'scope']") or
41
+ def insert_scope(xml)
42
+ xml.at("./*/sections") or
43
+ xml.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
44
+ "<sections><sentinel/></sections>"
45
+ xml.at("./*/sections/*") or xml.at("./*/sections") << "<sentinel/>"
46
+ ins = xml.at("//sections").elements.first
47
+ xml.at("//sections/clause[@type = 'scope']") or
46
48
  ins.previous =
47
49
  "<clause type='scope' #{add_id}><title>#{@i18n.scope}</title><p>"\
48
50
  "#{@i18n.clause_empty}</p></clause>"
49
- x&.at("//sentinel")&.remove
51
+ xml&.at("//sentinel")&.remove
50
52
  end
51
53
 
52
- def insert_norm_ref(x)
53
- x.at("//bibliography") or
54
- x.at("./*/annex[last()] | ./*/sections").next =
55
- "<bibliography><sentinel/></bibliography>"
56
- ins = x.at("//bibliography").elements.first
57
- x.at("//bibliography/references[@normative = 'true']") or
54
+ def insert_norm_ref(xml)
55
+ xml.at("//bibliography") or
56
+ xml.at("./*/annex[last()] | ./*/sections").next =
57
+ "<bibliography><sentinel/></bibliography>"
58
+ ins = xml.at("//bibliography").elements.first
59
+ xml.at("//bibliography/references[@normative = 'true']") or
58
60
  ins.previous = "<references #{add_id} normative='true'>"\
59
- "<title>#{@i18n.normref}</title></references>"
60
- x&.at("//sentinel")&.remove
61
+ "<title>#{@i18n.normref}</title></references>"
62
+ xml&.at("//sentinel")&.remove
61
63
  end
62
64
 
63
- def insert_terms(x)
64
- ins = x.at("//sections/clause[@type = 'scope']")
65
- x.at("//sections//terms") or
65
+ def insert_terms(xml)
66
+ ins = xml.at("//sections/clause[@type = 'scope']")
67
+ xml.at("//sections//terms") or
66
68
  ins.next = "<terms #{add_id}><title>#{@i18n.termsdef}</title></terms>"
67
69
  end
68
70
 
69
- def insert_symbols(x)
70
- ins = x.at("//sections/terms") ||
71
- x.at("//sections/clause[descendant::terms]")
72
- unless x.at("//sections//definitions")
71
+ def insert_symbols(xml)
72
+ ins = xml.at("//sections/terms") ||
73
+ xml.at("//sections/clause[descendant::terms]")
74
+ unless xml.at("//sections//definitions")
73
75
  ins.next = "<definitions #{add_id}>"\
74
- "<title>#{@i18n.symbolsabbrev}</title></definitions>"
76
+ "<title>#{@i18n.symbolsabbrev}</title></definitions>"
75
77
  end
76
78
  end
77
79
 
78
- def insert_conventions(x)
79
- ins = x.at("//sections//definitions") ||
80
- x.at("//sections/clause[descendant::definitions]")
81
- unless x.at("//sections/clause[@type = 'conventions']")
80
+ def insert_conventions(xml)
81
+ ins = xml.at("//sections//definitions") ||
82
+ xml.at("//sections/clause[descendant::definitions]")
83
+ unless xml.at("//sections/clause[@type = 'conventions']")
82
84
  ins.next = "<clause #{add_id} type='conventions'>"\
83
- "<title>#{@i18n.conventions}</title><p>"\
84
- "#{@i18n.clause_empty}</p></clause>"
85
+ "<title>#{@i18n.conventions}</title><p>"\
86
+ "#{@i18n.clause_empty}</p></clause>"
85
87
  end
86
88
  end
87
89
 
88
- def insert_empty_clauses(x)
89
- x.xpath("//terms[not(./term)][not(.//terms)]").each do |c|
90
+ def insert_empty_clauses(xml)
91
+ xml.xpath("//terms[not(./term)][not(.//terms)]").each do |c|
90
92
  insert_empty_clauses1(c, @i18n.clause_empty)
91
93
  end
92
- x.xpath("//definitions[not(./dl)]").each do |c|
94
+ xml.xpath("//definitions[not(./dl)]").each do |c|
93
95
  insert_empty_clauses1(c, @i18n.clause_empty)
94
96
  end
95
97
  end
96
98
 
97
- def insert_empty_clauses1(c, text)
98
- c.at("./p") and return
99
- ins = c.at("./title") or return
99
+ def insert_empty_clauses1(clause, text)
100
+ clause.at("./p") and return
101
+ ins = clause.at("./title") or return
100
102
  ins.next = "<p>#{text}</p>"
101
103
  end
102
104
 
@@ -114,14 +116,14 @@ module Asciidoctor
114
116
  next unless n.text?
115
117
 
116
118
  n.replace(HTMLEntities.new.encode(
117
- n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
118
- gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
119
+ n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
120
+ .gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
121
+ ))
119
122
  end
120
123
  xmldoc
121
124
  end
122
125
 
123
- def termdef_boilerplate_cleanup(xmldoc)
124
- end
126
+ def termdef_boilerplate_cleanup(xmldoc); end
125
127
 
126
128
  def terms_extract(div)
127
129
  internal = div.at("./terms[@type = 'internal']/title")
@@ -129,7 +131,7 @@ module Asciidoctor
129
131
  [internal, external]
130
132
  end
131
133
 
132
- def term_defs_boilerplate(div, source, term, preface, isodoc)
134
+ def term_defs_boilerplate(div, _source, _term, _preface, _isodoc)
133
135
  internal, external = terms_extract(div.parent)
134
136
  internal&.next_element&.name == "term" and
135
137
  internal.next = "<p>#{@i18n.internal_terms_boilerplate}</p>"
@@ -144,16 +146,20 @@ module Asciidoctor
144
146
  div.next = "<p>#{@i18n.term_def_boilerplate}</p>"
145
147
  end
146
148
 
147
- def section_names_terms_cleanup(x)
149
+ def section_names_terms_cleanup(xml)
148
150
  super
149
151
  replace_title(
150
- x, "//terms[@type = 'internal'] | "\
151
- "//clause[./terms[@type = 'internal']][not(./terms[@type = 'external'])]",
152
- @i18n&.internal_termsdef)
152
+ xml, "//terms[@type = 'internal'] | "\
153
+ "//clause[./terms[@type = 'internal']]"\
154
+ "[not(./terms[@type = 'external'])]",
155
+ @i18n&.internal_termsdef
156
+ )
153
157
  replace_title(
154
- x, "//terms[@type = 'external'] | "\
155
- "//clause[./terms[@type = 'external']][not(./terms[@type = 'internal'])]",
156
- @i18n&.external_termsdef)
158
+ xml, "//terms[@type = 'external'] | "\
159
+ "//clause[./terms[@type = 'external']]"\
160
+ "[not(./terms[@type = 'internal'])]",
161
+ @i18n&.external_termsdef
162
+ )
157
163
  end
158
164
 
159
165
  def symbols_cleanup(xmldoc)
@@ -193,12 +199,11 @@ module Asciidoctor
193
199
  # then title
194
200
  def sort_biblio_key(bib)
195
201
  pubclass = pub_class(bib)
196
- num = bib&.at("./docnumber")&.text
197
202
  id = bib&.at("./docidentifier[not(@type = 'DOI' or @type = "\
198
203
  "'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")
199
204
  metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
200
- abbrid = metaid unless /^\[\d+\]$/.match(metaid)
201
- type = id['type'] if id
205
+ abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
206
+ type = id["type"] if id
202
207
  title = bib&.at("./title[@type = 'main']")&.text ||
203
208
  bib&.at("./title")&.text || bib&.at("./formattedref")&.text
204
209
  "#{pubclass} :: #{type} :: #{id&.text || metaid} :: #{title}"
@@ -1,6 +1,7 @@
1
1
  require "asciidoctor"
2
2
  require "asciidoctor/standoc/converter"
3
3
  require "fileutils"
4
+ require "metanorma-utils"
4
5
  require_relative "./front"
5
6
  require_relative "./validate"
6
7
  require_relative "./cleanup"
@@ -107,16 +108,11 @@ module Asciidoctor
107
108
  return unless node.attr("keywords")
108
109
 
109
110
  node.attr("keywords").split(/, */).sort.each_with_index do |kw, i|
110
- xml.keyword (i.zero? ? strict_capitalize(kw) : kw)
111
+ kw_out = i.zero? ? Metanorma::Utils.strict_capitalize_first(kw) : kw
112
+ xml.keyword kw_out
111
113
  end
112
114
  end
113
115
 
114
- def strict_capitalize(str)
115
- letters = str.split("")
116
- letters.first.upcase!
117
- letters.join
118
- end
119
-
120
116
  def clause_parse(attrs, xml, node)
121
117
  node.option?("unnumbered") and attrs[:unnumbered] = true
122
118
  case sectiontype1(node)
@@ -17,13 +17,13 @@ module Asciidoctor
17
17
  { language: lang, format: "text/plain", type: type }
18
18
  end
19
19
 
20
- def title_english(node, xml)
21
- a = node.attr("title") || node.attr("title-en")
22
- xml.title **attr_code(title_attr("main")) do |t|
20
+ def title_defaultlang(node, xml)
21
+ a = node.attr("title") || node.attr("title-#{@lang}")
22
+ xml.title **attr_code(title_attr("main", @lang)) do |t|
23
23
  t << (Metanorma::Utils::asciidoc_sub(a) || node.title)
24
24
  end
25
- if a = node.attr("annextitle") || node.attr("annextitle-en")
26
- xml.title **attr_code(title_attr("annex")) do |t|
25
+ if a = node.attr("annextitle") || node.attr("annextitle-#{@lang}")
26
+ xml.title **attr_code(title_attr("annex", @lang)) do |t|
27
27
  t << Metanorma::Utils::asciidoc_sub(a)
28
28
  end
29
29
  end
@@ -32,7 +32,7 @@ module Asciidoctor
32
32
  def title_otherlangs(node, xml)
33
33
  node.attributes.each do |k, v|
34
34
  next unless /^(annex)?title-(?<lang>.+)$/ =~ k
35
- next if lang == "en"
35
+ next if lang == @lang
36
36
 
37
37
  type = /^annex/.match?(k) ? "annex" : "main"
38
38
  xml.title **attr_code(title_attr(type, lang)) do |t|
@@ -42,16 +42,17 @@ module Asciidoctor
42
42
  end
43
43
 
44
44
  def title(node, xml)
45
- super
45
+ title_defaultlang(node, xml)
46
+ title_otherlangs(node, xml)
46
47
  %w(subtitle amendment-title corrigendum-title).each do |t|
47
- other_title_english(node, xml, t)
48
+ other_title_defaultlang(node, xml, t)
48
49
  other_title_otherlangs(node, xml, t)
49
50
  end
50
51
  end
51
52
 
52
- def other_title_english(node, xml, type)
53
- a = node.attr(type) || node.attr("#{type}-en")
54
- xml.title **attr_code(title_attr(type.sub(/-title/, ""))) do |t|
53
+ def other_title_defaultlang(node, xml, type)
54
+ a = node.attr(type) || node.attr("#{type}-#{@lang}")
55
+ xml.title **attr_code(title_attr(type.sub(/-title/, ""), @lang)) do |t|
55
56
  t << Metanorma::Utils::asciidoc_sub(a)
56
57
  end
57
58
  end
@@ -59,7 +60,7 @@ module Asciidoctor
59
60
  def other_title_otherlangs(node, xml, type)
60
61
  node.attributes.each do |k, v|
61
62
  next unless m = /^#{type}-(?<lang>.+)$/.match(k)
62
- next if m[:lang] == "en"
63
+ next if m[:lang] == @lang
63
64
 
64
65
  xml.title **attr_code(title_attr(type.sub(/-title/, ""),
65
66
  m[:lang])) do |t|
@@ -84,30 +85,23 @@ module Asciidoctor
84
85
  def metadata_committee1(node, xml, suffix)
85
86
  xml.editorialgroup do |a|
86
87
  a.bureau ( node.attr("bureau#{suffix}") || "T")
87
- if node.attr("group#{suffix}")
88
- a.group **attr_code(type: node.attr("grouptype#{suffix}")) do |g|
89
- metadata_committee2(node, g, suffix, "")
90
- end
91
- end
92
- if node.attr("subgroup#{suffix}")
93
- a.subgroup **attr_code(type: node.attr("subgrouptype#{suffix}")) do |g|
94
- metadata_committee2(node, g, suffix, "sub")
95
- end
96
- end
97
- if node.attr("workgroup#{suffix}")
98
- a.workgroup **attr_code(type: node.attr("workgrouptype#{suffix}")) do |g|
99
- metadata_committee2(node, g, suffix, "work")
88
+ ["", "sub", "work"].each do |p|
89
+ next unless node.attr("#{p}group#{suffix}")
90
+
91
+ type = node.attr("#{p}grouptype#{suffix}")
92
+ a.send "#{p}group", **attr_code(type: type) do |g|
93
+ metadata_committee2(node, g, suffix, p)
100
94
  end
101
95
  end
102
96
  end
103
97
  end
104
98
 
105
- def metadata_committee2(node, g, suffix, prefix)
106
- g.name node.attr("#{prefix}group#{suffix}")
99
+ def metadata_committee2(node, group, suffix, prefix)
100
+ group.name node.attr("#{prefix}group#{suffix}")
107
101
  node.attr("#{prefix}groupacronym#{suffix}") and
108
- g.acronym node.attr("#{prefix}groupacronym#{suffix}")
102
+ group.acronym node.attr("#{prefix}groupacronym#{suffix}")
109
103
  if node.attr("#{prefix}groupyearstart#{suffix}")
110
- g.period do |p|
104
+ group.period do |p|
111
105
  p.start node.attr("#{prefix}groupyearstart#{suffix}")
112
106
  node.attr("#{prefix}groupacronym#{suffix}") and
113
107
  p.end node.attr("#{prefix}groupyearend#{suffix}")
@@ -134,9 +128,11 @@ module Asciidoctor
134
128
 
135
129
  def itu_id1(node, lang)
136
130
  bureau = node.attr("bureau") || "T"
137
- id = doctype(node) == "service-publication" ?
138
- @i18n.annex_to_itu_ob_abbrev.sub(/%/, node.attr("docnumber")) :
139
- "ITU-#{bureau} #{node.attr('docnumber')}"
131
+ id = if doctype(node) == "service-publication"
132
+ @i18n.annex_to_itu_ob_abbrev.sub(/%/, node.attr("docnumber"))
133
+ else
134
+ "ITU-#{bureau} #{node.attr('docnumber')}"
135
+ end
140
136
  id + (lang ? "-#{ITULANG[@lang]}" : "")
141
137
  end
142
138
 
@@ -165,16 +161,16 @@ module Asciidoctor
165
161
  def metadata_series(node, xml)
166
162
  node.attr("series") and
167
163
  xml.series **{ type: "main" } do |s|
168
- s.title node.attr("series")
169
- end
164
+ s.title node.attr("series")
165
+ end
170
166
  node.attr("series1") and
171
167
  xml.series **{ type: "secondary" } do |s|
172
- s.title node.attr("series1")
173
- end
168
+ s.title node.attr("series1")
169
+ end
174
170
  node.attr("series2") and
175
171
  xml.series **{ type: "tertiary" } do |s|
176
- s.title node.attr("series2")
177
- end
172
+ s.title node.attr("series2")
173
+ end
178
174
  end
179
175
 
180
176
  def metadata_recommendationstatus(node, xml)
@@ -222,9 +218,9 @@ module Asciidoctor
222
218
  end
223
219
  end
224
220
 
225
- def metadata_meeting_date(a, xml)
221
+ def metadata_meeting_date(val, xml)
226
222
  xml.meeting_date do |m|
227
- d = a.split("/")
223
+ d = val.split("/")
228
224
  if d.size > 1
229
225
  m.from d[0]
230
226
  m.to d[1]
@@ -234,9 +230,9 @@ module Asciidoctor
234
230
  end
235
231
  end
236
232
 
237
- def personal_role(node, c, suffix)
233
+ def personal_role(node, contrib, suffix)
238
234
  if node.attr("role#{suffix}")&.downcase == "rapporteur"
239
- c.role "raporteur", **{ type: "editor" }
235
+ contrib.role "raporteur", **{ type: "editor" }
240
236
  else
241
237
  super
242
238
  end
@@ -32,6 +32,18 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="section-title">
36
+ <element name="title">
37
+ <zeroOrMore>
38
+ <ref name="TextElement"/>
39
+ </zeroOrMore>
40
+ </element>
41
+ <zeroOrMore>
42
+ <element name="variant-title">
43
+ <ref name="TypedTitleString"/>
44
+ </element>
45
+ </zeroOrMore>
46
+ </define>
35
47
  <define name="hyperlink">
36
48
  <element name="link">
37
49
  <attribute name="target">
@@ -158,15 +170,17 @@
158
170
  <data type="boolean"/>
159
171
  </attribute>
160
172
  </optional>
161
- <attribute name="type">
162
- <choice>
163
- <value>roman</value>
164
- <value>alphabet</value>
165
- <value>arabic</value>
166
- <value>roman_upper</value>
167
- <value>alphabet_upper</value>
168
- </choice>
169
- </attribute>
173
+ <optional>
174
+ <attribute name="type">
175
+ <choice>
176
+ <value>roman</value>
177
+ <value>alphabet</value>
178
+ <value>arabic</value>
179
+ <value>roman_upper</value>
180
+ <value>alphabet_upper</value>
181
+ </choice>
182
+ </attribute>
183
+ </optional>
170
184
  <oneOrMore>
171
185
  <ref name="li"/>
172
186
  </oneOrMore>
@@ -976,6 +990,16 @@
976
990
  <data type="boolean"/>
977
991
  </attribute>
978
992
  </optional>
993
+ <optional>
994
+ <attribute name="linkmention">
995
+ <data type="boolean"/>
996
+ </attribute>
997
+ </optional>
998
+ <optional>
999
+ <attribute name="linkref">
1000
+ <data type="boolean"/>
1001
+ </attribute>
1002
+ </optional>
979
1003
  <optional>
980
1004
  <element name="refterm">
981
1005
  <zeroOrMore>
@@ -1011,8 +1035,14 @@
1011
1035
  <ref name="imagemap"/>
1012
1036
  <ref name="svgmap"/>
1013
1037
  <ref name="inputform"/>
1038
+ <ref name="toc"/>
1014
1039
  </choice>
1015
1040
  </define>
1041
+ <define name="toc">
1042
+ <element name="toc">
1043
+ <ref name="ul"/>
1044
+ </element>
1045
+ </define>
1016
1046
  <define name="inputform">
1017
1047
  <element name="form">
1018
1048
  <attribute name="id">
@@ -1254,6 +1284,12 @@
1254
1284
  <optional>
1255
1285
  <attribute name="type"/>
1256
1286
  </optional>
1287
+ <optional>
1288
+ <attribute name="identifier"/>
1289
+ </optional>
1290
+ <optional>
1291
+ <attribute name="prefix"/>
1292
+ </optional>
1257
1293
  <text/>
1258
1294
  </define>
1259
1295
  <define name="ics">
@@ -1674,7 +1710,9 @@
1674
1710
  <zeroOrMore>
1675
1711
  <ref name="termgrammar"/>
1676
1712
  </zeroOrMore>
1677
- <ref name="definition"/>
1713
+ <oneOrMore>
1714
+ <ref name="termdefinition"/>
1715
+ </oneOrMore>
1678
1716
  <zeroOrMore>
1679
1717
  <ref name="termnote"/>
1680
1718
  </zeroOrMore>
@@ -1737,7 +1775,7 @@
1737
1775
  </oneOrMore>
1738
1776
  </element>
1739
1777
  </define>
1740
- <define name="definition">
1778
+ <define name="termdefinition">
1741
1779
  <element name="definition">
1742
1780
  <oneOrMore>
1743
1781
  <choice>
@@ -1746,6 +1784,9 @@
1746
1784
  <ref name="formula"/>
1747
1785
  </choice>
1748
1786
  </oneOrMore>
1787
+ <zeroOrMore>
1788
+ <ref name="termsource"/>
1789
+ </zeroOrMore>
1749
1790
  </element>
1750
1791
  </define>
1751
1792
  <define name="termnote">