metanorma-itu 2.0.0 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,7 @@ module IsoDoc
11
11
  set(:logo_comb, fileloc("itu-document-comb.png"))
12
12
  set(:logo_word, fileloc(n))
13
13
  set(:logo_sp, fileloc("logo-sp.png"))
14
+ @isodoc = IsoDoc::ITU::HtmlConvert.new({})
14
15
  end
15
16
 
16
17
  def fileloc(file)
@@ -19,30 +20,30 @@ module IsoDoc
19
20
  end
20
21
 
21
22
  def title(isoxml, _out)
22
- main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
23
- "[@type = 'main']"))&.text
24
- set(:doctitle, main)
25
- main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
26
- "[@type = 'subtitle']"))&.text
27
- set(:docsubtitle, main)
28
- main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
29
- "[@type = 'amendment']"))&.text
30
- set(:amendmenttitle, main)
31
- main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"\
32
- "[@type = 'corrigendum']"))&.text
33
- set(:corrigendumtitle, main)
34
- series = isoxml&.at(ns("//bibdata/series[@type='main']/title"))&.text
35
- set(:series, series)
36
- series1 =
37
- isoxml&.at(ns("//bibdata/series[@type='secondary']/title"))&.text
38
- set(:series1, series1)
39
- series2 =
40
- isoxml&.at(ns("//bibdata/series[@type='tertiary']/title"))&.text
41
- set(:series2, series2)
42
- annext = isoxml&.at(ns("//bibdata/title[@type='annex']"))&.text
43
- set(:annextitle, annext)
44
- annext = isoxml&.at(ns("//bibdata/title[@type='position-sp']"))&.text
45
- set(:positiontitle, annext)
23
+ { doctitle: "//bibdata/title[@language='#{@lang}'][@type = 'main']",
24
+ docsubtitle: "//bibdata/title[@language='#{@lang}']"\
25
+ "[@type = 'subtitle']",
26
+ amendmenttitle: "//bibdata/title[@language='#{@lang}']"\
27
+ "[@type = 'amendment']",
28
+ corrigendumtitle: "//bibdata/title[@language='#{@lang}']"\
29
+ "[@type = 'corrigendum']",
30
+ series: "//bibdata/series[@type='main']/title",
31
+ series1: "//bibdata/series[@type='secondary']/title",
32
+ series2: "//bibdata/series[@type='tertiary']/title",
33
+ annextitle: "//bibdata/title[@type='annex']",
34
+ positiontitle: "//bibdata/title[@type='position-sp']" }.each do |k, v|
35
+ titleset(isoxml, k, v)
36
+ end
37
+ end
38
+
39
+ def titleset(isoxml, key, xpath)
40
+ value = isoxml.at(ns(xpath)) or return
41
+ out = @isodoc.noko do |xml|
42
+ xml.span do |s|
43
+ value.children.each { |c| @isodoc.parse(c, s) }
44
+ end
45
+ end.join
46
+ set(key, out.sub(%r{^<span>}, "").sub(%r{</span>$}, ""))
46
47
  end
47
48
 
48
49
  def subtitle(_isoxml, _out)
@@ -174,6 +174,19 @@ module IsoDoc
174
174
  t.children = "<strong>#{t.children.to_xml}</strong>"
175
175
  end
176
176
 
177
+ def ol_depth(node)
178
+ return super unless node["class"] == "steps" ||
179
+ node.at(".//ancestor::xmlns:ol[@class = 'steps']")
180
+
181
+ depth = node.ancestors("ul, ol").size + 1
182
+ type = :arabic
183
+ type = :alphabet if [2, 7].include? depth
184
+ type = :roman if [3, 8].include? depth
185
+ type = :alphabet_upper if [4, 9].include? depth
186
+ type = :roman_upper if [5, 10].include? depth
187
+ type
188
+ end
189
+
177
190
  include Init
178
191
  end
179
192
  end
@@ -44,24 +44,26 @@ module IsoDoc
44
44
  end
45
45
  end
46
46
 
47
- def bracket_if_num(x)
48
- return nil if x.nil?
47
+ def bracket_if_num(num)
48
+ return nil if num.nil?
49
49
 
50
- x = x.text.sub(/^\[/, "").sub(/\]$/, "")
51
- "[#{x}]"
50
+ num = num.text.sub(/^\[/, "").sub(/\]$/, "")
51
+ "[#{num}]"
52
52
  end
53
53
 
54
- def reference_format(b, r)
55
- reference_format_start(b, r)
56
- reference_format_title(b, r)
54
+ def reference_format(biblio, ref)
55
+ reference_format_start(biblio, ref)
56
+ reference_format_title(biblio, ref)
57
57
  end
58
58
 
59
- def titlecase(s)
60
- s.gsub(/ |_|-/, " ").split(/ /).map(&:capitalize).join(" ")
59
+ def titlecase(str)
60
+ str.gsub(/ |_|-/, " ").split(/ /).map(&:capitalize).join(" ")
61
61
  end
62
62
 
63
- def pref_ref_code(b)
64
- b.at(ns("./docidentifier[@type = 'ITU']")) || super
63
+ def pref_ref_code(bibitem)
64
+ ret = bibitem.xpath(ns("./docidentifier[@type = 'ITU']"))
65
+ ret.empty? and ret = super
66
+ ret
65
67
  end
66
68
 
67
69
  IGNORE_IDS = "@type = 'DOI' or @type = 'ISSN' or @type = 'ISBN' or "\
@@ -84,7 +86,7 @@ module IsoDoc
84
86
  else
85
87
  docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
86
88
  end
87
- end.join(" | ")
89
+ end.join("&#xA0;| ")
88
90
  end
89
91
 
90
92
  def doctype_title(id)
@@ -98,20 +100,28 @@ module IsoDoc
98
100
  end
99
101
  end
100
102
 
101
- def reference_format_start(b, r)
102
- id = multi_bibitem_ref_code(b)
103
+ def unbracket(ident)
104
+ if ident.respond_to?(:size)
105
+ ident.map { |x| unbracket1(x) }.join("&#xA0;| ")
106
+ else
107
+ unbracket1(ident)
108
+ end
109
+ end
110
+
111
+ def reference_format_start(bib, r)
112
+ id = multi_bibitem_ref_code(bib)
103
113
  id1 = render_multi_identifiers(id)
104
114
  r << id1
105
- date = b.at(ns("./date[@type = 'published']")) and
115
+ date = bib.at(ns("./date[@type = 'published']")) and
106
116
  r << " (#{date.text.sub(/-.*$/, '')})"
107
117
  r << ", " if date || !id1.empty?
108
118
  end
109
119
 
110
- def reference_format_title(b, r)
111
- if ftitle = b.at(ns("./formattedref"))
120
+ def reference_format_title(bib, r)
121
+ if ftitle = bib.at(ns("./formattedref"))
112
122
  ftitle&.children&.each { |n| parse(n, r) }
113
123
  /\.$/.match(ftitle&.text) or r << "."
114
- elsif title = iso_title(b)
124
+ elsif title = iso_title(bib)
115
125
  r.i do |i|
116
126
  title&.children&.each { |n| parse(n, i) }
117
127
  end
@@ -16,11 +16,16 @@ module IsoDoc
16
16
  end
17
17
  end
18
18
 
19
- def annex_names(clause, num)
19
+ def annex_name_anchors(clause, num)
20
20
  lbl = annextype(clause)
21
- @anchors[clause["id"]] =
22
- { label: annex_name_lbl(clause, num), type: "clause",
23
- xref: l10n("#{lbl} #{num}"), level: 1, value: num }
21
+ { label: annex_name_lbl(clause, num),
22
+ elem: lbl,
23
+ type: "clause", value: num.to_s, level: 1,
24
+ xref: l10n("#{lbl} #{num}") }
25
+ end
26
+
27
+ def annex_names(clause, num)
28
+ @anchors[clause["id"]] = annex_name_anchors(clause, num)
24
29
  if a = single_annex_special_section(clause)
25
30
  annex_names1(a, num.to_s, 1)
26
31
  else
@@ -36,7 +41,7 @@ module IsoDoc
36
41
 
37
42
  def annex_names1(clause, num, level)
38
43
  @anchors[clause["id"]] =
39
- { label: num,
44
+ { label: num, elem: @labels["annex_subclause"],
40
45
  xref: @doctype == "resolution" ? num : l10n("#{@labels['annex_subclause']} #{num}"),
41
46
  level: level, type: "clause" }
42
47
  i = Counter.new
@@ -65,7 +70,7 @@ module IsoDoc
65
70
  lbl = @doctype == "resolution" ? @labels["section"] : @labels["clause"]
66
71
  @anchors[clause["id"]] =
67
72
  { label: num.print, xref: l10n("#{lbl} #{num.print}"),
68
- level: lvl, type: "clause" }
73
+ level: lvl, type: "clause", elem: lbl }
69
74
  i = Counter.new
70
75
  clause.xpath(ns(SUBCLAUSES)).each do |c|
71
76
  i.increment(c)
@@ -77,6 +82,7 @@ module IsoDoc
77
82
  def section_names1(clause, num, level)
78
83
  @anchors[clause["id"]] =
79
84
  { label: num, level: level,
85
+ elem: @doctype == "resolution" ? "" : @labels["clause"],
80
86
  xref: @doctype == "resolution" ? num : l10n("#{@labels['clause']} #{num}") }
81
87
  i = Counter.new
82
88
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -173,9 +173,11 @@
173
173
  <data type="dateTime"/>
174
174
  </attribute>
175
175
  </optional>
176
- <attribute name="from">
177
- <data type="IDREF"/>
178
- </attribute>
176
+ <optional>
177
+ <attribute name="from">
178
+ <data type="IDREF"/>
179
+ </attribute>
180
+ </optional>
179
181
  <optional>
180
182
  <attribute name="to">
181
183
  <data type="IDREF"/>
@@ -209,9 +209,6 @@
209
209
  <zeroOrMore>
210
210
  <ref name="contact"/>
211
211
  </zeroOrMore>
212
- <zeroOrMore>
213
- <ref name="uri"/>
214
- </zeroOrMore>
215
212
  </element>
216
213
  </define>
217
214
  <define name="fullname">
@@ -401,9 +398,9 @@
401
398
  <choice>
402
399
  <!-- iso191606 TODO -->
403
400
  <group>
404
- <oneOrMore>
401
+ <zeroOrMore>
405
402
  <ref name="street"/>
406
- </oneOrMore>
403
+ </zeroOrMore>
407
404
  <ref name="city"/>
408
405
  <optional>
409
406
  <ref name="state"/>
@@ -828,6 +825,11 @@
828
825
  <optional>
829
826
  <attribute name="scope"/>
830
827
  </optional>
828
+ <optional>
829
+ <attribute name="primary">
830
+ <data type="boolean"/>
831
+ </attribute>
832
+ </optional>
831
833
  <text/>
832
834
  </element>
833
835
  </define>
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="index">
36
+ <element name="index">
37
+ <optional>
38
+ <attribute name="to">
39
+ <data type="IDREF"/>
40
+ </attribute>
41
+ </optional>
42
+ <element name="primary">
43
+ <oneOrMore>
44
+ <choice>
45
+ <ref name="PureTextElement"/>
46
+ <ref name="stem"/>
47
+ </choice>
48
+ </oneOrMore>
49
+ </element>
50
+ <optional>
51
+ <element name="secondary">
52
+ <oneOrMore>
53
+ <choice>
54
+ <ref name="PureTextElement"/>
55
+ <ref name="stem"/>
56
+ </choice>
57
+ </oneOrMore>
58
+ </element>
59
+ </optional>
60
+ <optional>
61
+ <element name="tertiary">
62
+ <oneOrMore>
63
+ <choice>
64
+ <ref name="PureTextElement"/>
65
+ <ref name="stem"/>
66
+ </choice>
67
+ </oneOrMore>
68
+ </element>
69
+ </optional>
70
+ </element>
71
+ </define>
35
72
  <define name="bibitem">
36
73
  <element name="bibitem">
37
74
  <attribute name="id">
@@ -115,9 +152,7 @@
115
152
  <data type="boolean"/>
116
153
  </attribute>
117
154
  </optional>
118
- <oneOrMore>
119
- <ref name="PureTextElement"/>
120
- </oneOrMore>
155
+ <ref name="XrefBody"/>
121
156
  </element>
122
157
  </define>
123
158
  <define name="erefType">
@@ -151,6 +186,42 @@
151
186
  <ref name="PureTextElement"/>
152
187
  </oneOrMore>
153
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
154
225
  <define name="ul">
155
226
  <element name="ul">
156
227
  <attribute name="id">
@@ -1027,6 +1098,26 @@
1027
1098
  </zeroOrMore>
1028
1099
  </element>
1029
1100
  </define>
1101
+ <define name="sub">
1102
+ <element name="sub">
1103
+ <zeroOrMore>
1104
+ <choice>
1105
+ <ref name="PureTextElement"/>
1106
+ <ref name="stem"/>
1107
+ </choice>
1108
+ </zeroOrMore>
1109
+ </element>
1110
+ </define>
1111
+ <define name="sup">
1112
+ <element name="sup">
1113
+ <zeroOrMore>
1114
+ <choice>
1115
+ <ref name="PureTextElement"/>
1116
+ <ref name="stem"/>
1117
+ </choice>
1118
+ </zeroOrMore>
1119
+ </element>
1120
+ </define>
1030
1121
  <define name="pagebreak">
1031
1122
  <element name="pagebreak">
1032
1123
  <optional>
@@ -1041,6 +1132,16 @@
1041
1132
  </define>
1042
1133
  </include>
1043
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1044
1145
  <define name="MultilingualRenderingType">
1045
1146
  <choice>
1046
1147
  <value>common</value>
@@ -2216,7 +2317,18 @@
2216
2317
  <ref name="MultilingualRenderingType"/>
2217
2318
  </attribute>
2218
2319
  </optional>
2219
- <ref name="paragraph"/>
2320
+ <oneOrMore>
2321
+ <choice>
2322
+ <ref name="formula"/>
2323
+ <ref name="ul"/>
2324
+ <ref name="ol"/>
2325
+ <ref name="dl"/>
2326
+ <ref name="quote"/>
2327
+ <ref name="sourcecode"/>
2328
+ <ref name="paragraph"/>
2329
+ <ref name="figure"/>
2330
+ </choice>
2331
+ </oneOrMore>
2220
2332
  </element>
2221
2333
  </define>
2222
2334
  <define name="termsource">
@@ -2563,4 +2675,30 @@
2563
2675
  </zeroOrMore>
2564
2676
  </element>
2565
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2566
2704
  </grammar>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "2.0.0".freeze
3
+ VERSION = "2.0.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities