metanorma-itu 2.0.2 → 2.0.3

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
@@ -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">
@@ -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>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "2.0.2".freeze
3
+ VERSION = "2.0.3".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.2
4
+ version: 2.0.3
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-22 00:00:00.000000000 Z
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities