metanorma-itu 1.3.9 → 1.3.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -112,11 +112,12 @@ module IsoDoc
112
112
  pubdate and set(:pubdate_ddMMMyyyy, monthyr(pubdate.text))
113
113
  pubdate = isoxml.at(ns("//bibdata/date[not(@format)][@type = 'published']")) ||
114
114
  isoxml.at(ns("//bibdata/copyright/from"))
115
- pubdate and set(:placedate_year,
116
- @labels["placedate"].sub(/%/,
117
- pubdate.text.sub(
118
- /^(\d\d\d\d).*$/, "\\1"
119
- )))
115
+ pubdate and
116
+ set(:placedate_year,
117
+ @labels["placedate"].sub(/%/,
118
+ pubdate.text.sub(
119
+ /^(\d\d\d\d).*$/, "\\1"
120
+ )))
120
121
  end
121
122
 
122
123
  def monthyr(isodate)
@@ -153,7 +154,8 @@ module IsoDoc
153
154
  m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)-(?<dd>\d\d)/.match isodate
154
155
  return isodate unless m && m[:yr] && m[:mo] && m[:dd]
155
156
 
156
- mmm = DateTime.parse(isodate).localize(@lang.to_sym).to_additional_s("MMM")
157
+ mmm = DateTime.parse(isodate).localize(@lang.to_sym)
158
+ .to_additional_s("MMM")
157
159
  @i18n.l10n("#{m[:dd]} #{mmm} #{m[:yr]}")
158
160
  end
159
161
 
@@ -188,21 +190,19 @@ module IsoDoc
188
190
  set(:meeting, a)
189
191
  set(:meeting_acronym, a)
190
192
  end
191
- a = isoxml&.at(ns("//bibdata/ext/meeting/@acronym"))&.text and set(
192
- :meeting_acronym, a
193
- )
194
- a = isoxml&.at(ns("//bibdata/ext/meeting-place"))&.text and set(
195
- :meeting_place, a
196
- )
197
- a = isoxml&.at(ns("//bibdata/ext/intended-type"))&.text and set(
198
- :intended_type, a
199
- )
193
+ a = isoxml&.at(ns("//bibdata/ext/meeting/@acronym"))&.text and
194
+ set(:meeting_acronym, a)
195
+ a = isoxml&.at(ns("//bibdata/ext/meeting-place"))&.text and
196
+ set(:meeting_place, a)
197
+ a = isoxml&.at(ns("//bibdata/ext/intended-type"))&.text and
198
+ set(:intended_type, a)
200
199
  a = isoxml&.at(ns("//bibdata/ext/source"))&.text and set(:source, a)
201
200
  meeting(isoxml)
202
201
  end
203
202
 
204
203
  def meeting(isoxml)
205
- resolution = isoxml&.at(ns("//bibdata/ext/doctype"))&.text == "resolution"
204
+ resolution =
205
+ isoxml&.at(ns("//bibdata/ext/doctype"))&.text == "resolution"
206
206
  if o = isoxml&.at(ns("//bibdata/ext/meeting-date/on"))&.text
207
207
  set(:meeting_date, resolution ? ddMMMMYYYY(o, nil) : ddMMMYYYY(o))
208
208
  elsif f = isoxml&.at(ns("//bibdata/ext/meeting-date/from"))&.text
@@ -11,7 +11,7 @@ module IsoDoc
11
11
  end
12
12
 
13
13
  def prefix_container(container, linkend, _target)
14
- l10n("#{linkend} #{@i18n.get["in"]} #{@xrefs.anchor(container, :xref)}")
14
+ l10n("#{linkend} #{@i18n.get['in']} #{@xrefs.anchor(container, :xref)}")
15
15
  end
16
16
 
17
17
  def eref(docxml)
@@ -32,12 +32,13 @@ module IsoDoc
32
32
  end
33
33
  end
34
34
 
35
- def eref1(f)
36
- get_eref_linkend(f)
35
+ def eref1(elem)
36
+ get_eref_linkend(elem)
37
37
  end
38
38
 
39
- def note1(f)
40
- return if f["type"] == "title-footnote"
39
+ def note1(elem)
40
+ return if elem["type"] == "title-footnote"
41
+
41
42
  super
42
43
  end
43
44
 
@@ -46,71 +47,76 @@ module IsoDoc
46
47
  !c.text? || /\S/.match(c)
47
48
  end
48
49
  return unless contents.empty?
49
- link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
50
+
51
+ link = anchor_linkend(node,
52
+ docid_l10n(node["target"] || node["citeas"]))
50
53
  link && !/^\[.*\]$/.match(link) and link = "[#{link}]"
51
- link += eref_localities(node.xpath(ns("./locality | ./localityStack")), link, node)
52
- non_locality_elems(node).each { |n| n.remove }
54
+ link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
55
+ link, node)
56
+ non_locality_elems(node).each(&:remove)
53
57
  node.add_child(link)
54
58
  end
55
59
 
56
- def bibdata_i18n(b)
60
+ def bibdata_i18n(bib)
57
61
  super
58
- bibdata_dates(b)
59
- bibdata_title(b)
60
- amendment_id(b)
62
+ bibdata_dates(bib)
63
+ bibdata_title(bib)
64
+ amendment_id(bib)
61
65
  end
62
66
 
63
- def bibdata_dates(b)
64
- b.xpath(ns("./date")).each do |d|
67
+ def bibdata_dates(bib)
68
+ bib.xpath(ns("./date")).each do |d|
65
69
  d.next = d.dup
66
70
  d.next["format"] = "ddMMMyyyy"
67
71
  d.next.children = ddMMMyyyy(d.text)
68
72
  end
69
73
  end
70
74
 
71
- def bibdata_title(b)
72
- case b&.at(ns("./ext/doctype"))&.text
73
- when "service-publication" then bibdata_title_service_population(b)
74
- when "resolution" then bibdata_title_resolution(b)
75
+ def bibdata_title(bib)
76
+ case bib&.at(ns("./ext/doctype"))&.text
77
+ when "service-publication" then bibdata_title_service_population(bib)
78
+ when "resolution" then bibdata_title_resolution(bib)
75
79
  end
76
80
  end
77
81
 
78
- def bibdata_title_resolution(b)
79
- num = b&.at(ns("./docnumber"))&.text
80
- place = b&.at(ns("./ext/meeting-place"))&.text
81
- ed = b&.at(ns("./edition"))&.text
82
- rev = (ed && ed != "1") ? "#{@i18n.get["revision_abbreviation"]} " : ""
83
- year = b&.at(ns("./ext/meeting-date/from | ./ext/meeting-date/on"))&.text&.gsub(/-.*$/, "")
84
- num = b&.at(ns("./docnumber"))&.text
85
- text = @i18n.l10n("#{@i18n.get['doctype_dict']['resolution'].upcase} #{num} (#{rev}#{place}, #{year})")
86
- ins = b.at(ns("./title"))
87
- ins.next = <<~END
88
- <title language="#{@lang}" format="text/plain" type="resolution">#{text}</title>
89
- <title language="#{@lang}" format="text/plain" type="resolution-placedate">#{place}, #{year}</title>
90
- END
91
- end
92
-
93
- def bibdata_title_service_population(b)
94
- date = b&.at(ns("./date[@type = 'published']"))&.text or return
82
+ def bibdata_title_resolution(bib)
83
+ place = bib&.at(ns("./ext/meeting-place"))&.text
84
+ ed = bib&.at(ns("./edition"))&.text
85
+ rev = ed && ed != "1" ? "#{@i18n.get['revision_abbreviation']} " : ""
86
+ year = bib&.at(ns("./ext/meeting-date/from | ./ext/meeting-date/on"))
87
+ &.text&.gsub(/-.*$/, "")
88
+ num = bib&.at(ns("./docnumber"))&.text
89
+ text = @i18n.l10n("#{@i18n.get['doctype_dict']['resolution'].upcase} "\
90
+ "#{num} (#{rev}#{place}, #{year})")
91
+ ins = bib.at(ns("./title"))
92
+ ins.next = <<~INS
93
+ <title language="#{@lang}" format="text/plain" type="resolution">#{text}</title>
94
+ <title language="#{@lang}" format="text/plain" type="resolution-placedate">#{place}, #{year}</title>
95
+ INS
96
+ end
97
+
98
+ def bibdata_title_service_population(bib)
99
+ date = bib&.at(ns("./date[@type = 'published']"))&.text or return
95
100
  text = l10n(@i18n.get["position_on"].sub(/%/, ddmmmmyyyy(date)))
96
- ins = b.at(ns("./title"))
97
- ins.next = <<~END
98
- <title language="#{@lang}" format="text/plain" type="position-sp">#{text}</title>
99
- END
101
+ ins = bib.at(ns("./title"))
102
+ ins.next = <<~INS
103
+ <title language="#{@lang}" format="text/plain" type="position-sp">#{text}</title>
104
+ INS
100
105
  end
101
106
 
102
107
  def ddMMMyyyy(date)
103
- d = date.split(/-/).map { |x| x.sub(/^0/, "") }
104
- if @lang == "zh"
105
- d[0] += "" if d.dig(0)
106
- d[1] += "" if d.dig(1)
107
- d[2] += "" if d.dig(2)
108
- d.join("")
109
- elsif @lang == "ar"
110
- d[1] = ::RomanNumerals.to_roman(d[1].to_i).upcase if d.dig(1)
108
+ d = date.split("-").map { |x| x.sub(/^0/, "") }
109
+ case @lang
110
+ when "zh"
111
+ d[0] += "" if d[0]
112
+ d[1] += "" if d[1]
113
+ d[2] += "" if d[2]
114
+ d.join
115
+ when "ar"
116
+ d[1] = ::RomanNumerals.to_roman(d[1].to_i).upcase if d[1]
111
117
  d.join(".")
112
118
  else
113
- d[1] = ::RomanNumerals.to_roman(d[1].to_i).upcase if d.dig(1)
119
+ d[1] = ::RomanNumerals.to_roman(d[1].to_i).upcase if d[1]
114
120
  d.reverse.join(".")
115
121
  end
116
122
  end
@@ -119,16 +125,16 @@ module IsoDoc
119
125
  if @lang == "zh"
120
126
  ddMMMyyyy(date)
121
127
  else
122
- d = date.split(/-/)
123
- d[1] = @meta.months[d[1].to_sym] if d.dig(1)
124
- d[2] = d[2].sub(/^0/, "") if d.dig(2)
128
+ d = date.split("-")
129
+ d[1] = @meta.months[d[1].to_sym] if d[1]
130
+ d[2] = d[2].sub(/^0/, "") if d[2]
125
131
  l10n(d.reverse.join(" "))
126
132
  end
127
133
  end
128
134
 
129
- def amendment_id(b)
135
+ def amendment_id(bib)
130
136
  %w(amendment corrigendum).each do |w|
131
- if dn = b.at(ns("./ext/structuredidentifier/#{w}"))
137
+ if dn = bib.at(ns("./ext/structuredidentifier/#{w}"))
132
138
  dn["language"] = ""
133
139
  dn.next = dn.dup
134
140
  dn.next["language"] = @lang
@@ -138,32 +144,37 @@ module IsoDoc
138
144
  end
139
145
 
140
146
  def twitter_cldr_localiser_symbols
141
- {group: "'"}
142
- end
143
-
144
- def clause1(f)
145
- return super unless f&.at(ns("//bibdata/ext/doctype"))&.text == "resolution"
146
- return super unless %w(sections bibliography).include? f.parent.name
147
- return if @suppressheadingnumbers || f["unnumbered"]
148
- t = f.at(ns("./title")) and t["depth"] = "1"
149
- lbl = @xrefs.anchor(f['id'], :label, false) or return
150
- f.elements.first.previous =
151
- "<p keep-with-next='true' class='supertitle'>#{@i18n.get['section'].upcase} #{lbl}</p>"
152
- end
153
-
154
- def annex1(f)
155
- return super unless f&.at(ns("//bibdata/ext/doctype"))&.text == "resolution"
156
- lbl = @xrefs.anchor(f['id'], :label)
157
- subhead = (@i18n.l10n("(#{@i18n.get['to']} ") +
158
- f.at(ns("//bibdata/title[@type = 'resolution']")).children.to_xml + @i18n.l10n(")"))
159
- f.elements.first.previous = "<p class='supertitle'>#{lbl}<br/>#{subhead}</p>"
160
- if t = f.at(ns("./title"))
147
+ { group: "'" }
148
+ end
149
+
150
+ def clause1(elem)
151
+ return super unless elem&.at(ns("//bibdata/ext/doctype"))&.text ==
152
+ "resolution"
153
+ return super unless %w(sections bibliography).include? elem.parent.name
154
+ return if @suppressheadingnumbers || elem["unnumbered"]
155
+
156
+ t = elem.at(ns("./title")) and t["depth"] = "1"
157
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
158
+ elem.elements.first.previous =
159
+ "<p keep-with-next='true' class='supertitle'>"\
160
+ "#{@i18n.get['section'].upcase} #{lbl}</p>"
161
+ end
162
+
163
+ def annex1(elem)
164
+ return super unless elem&.at(ns("//bibdata/ext/doctype"))&.text ==
165
+ "resolution"
166
+
167
+ lbl = @xrefs.anchor(elem["id"], :label)
168
+ subhead = (@i18n.l10n("(#{@i18n.get['to']} ") +
169
+ elem.at(ns("//bibdata/title[@type = 'resolution']"))
170
+ .children.to_xml + @i18n.l10n(")"))
171
+ elem.elements.first.previous =
172
+ "<p class='supertitle'>#{lbl}<br/>#{subhead}</p>"
173
+ t = elem.at(ns("./title")) and
161
174
  t.children = "<strong>#{t.children.to_xml}</strong>"
162
- end
163
175
  end
164
176
 
165
177
  include Init
166
178
  end
167
179
  end
168
180
  end
169
-
@@ -9,8 +9,7 @@ module IsoDoc
9
9
  end
10
10
  end
11
11
 
12
- def word_term_cleanup(docxml)
13
- end
12
+ def word_term_cleanup(docxml); end
14
13
 
15
14
  def word_cleanup(docxml)
16
15
  word_footnote_cleanup(docxml)
@@ -77,26 +76,35 @@ module IsoDoc
77
76
  @wordstylesheet&.close
78
77
  end
79
78
  Html2Doc.process(
80
- result, filename: filename,
81
- stylesheet: @wordstylesheet&.path,
82
- header_file: header&.path, dir: dir,
83
- asciimathdelims: [@openmathdelim, @closemathdelim],
84
- liststyles: { ul: @ulstyle, ol: @olstyle, steps: "l4" })
79
+ result, filename: filename,
80
+ stylesheet: @wordstylesheet&.path,
81
+ header_file: header&.path, dir: dir,
82
+ asciimathdelims: [@openmathdelim, @closemathdelim],
83
+ liststyles: { ul: @ulstyle, ol: @olstyle, steps: "l4" }
84
+ )
85
85
  header&.unlink
86
86
  @wordstylesheet&.unlink
87
87
  end
88
88
 
89
89
  def authority_hdr_cleanup(docxml)
90
- docxml&.xpath("//div[@id = 'draft-warning']").each do |d|
90
+ authority_hdr_cleanup1(docxml)
91
+ authority_hdr_cleanup2(docxml)
92
+ end
93
+
94
+ def authority_hdr_cleanup1(docxml)
95
+ docxml&.xpath("//div[@id = 'draft-warning']")&.each do |d|
91
96
  d.xpath(".//h1 | .//h2").each do |p|
92
97
  p.name = "p"
93
98
  p["class"] = "draftwarningHdr"
94
99
  end
95
100
  end
101
+ end
102
+
103
+ def authority_hdr_cleanup2(docxml)
96
104
  %w(copyright license legal).each do |t|
97
- docxml&.xpath("//div[@class = 'boilerplate-#{t}']").each do |d|
98
- p = d&.at("./descendant::h1[2]") and
99
- p.previous = "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
105
+ docxml&.xpath("//div[@class = 'boilerplate-#{t}']")&.each do |d|
106
+ para = d&.at("./descendant::h1[2]") and
107
+ para.previous = "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
100
108
  d.xpath(".//h1 | .//h2").each do |p|
101
109
  p.name = "p"
102
110
  p["class"] = "boilerplateHdr"
@@ -114,14 +122,15 @@ module IsoDoc
114
122
  auth = docxml.at("//div[@class = 'boilerplate-#{t}']")
115
123
  auth.remove if auth && !dest
116
124
  next unless auth && dest
117
- t == "copyright" and p = auth&.at(".//p") and
118
- p["class"] = "boilerplateHdr"
119
- auth&.xpath(".//p[not(@class)]")&.each_with_index do |p, i|
125
+
126
+ t == "copyright" and para = auth&.at(".//p") and
127
+ para["class"] = "boilerplateHdr"
128
+ auth&.xpath(".//p[not(@class)]")&.each_with_index do |p, _i|
120
129
  p["class"] = "boilerplate"
121
- #i == 0 && t == "copyright" and p["style"] = "text-align:center;"
130
+ # i == 0 && t == "copyright" and p["style"] = "text-align:center;"
122
131
  end
123
132
  t == "copyright" or
124
- auth << "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
133
+ auth << "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
125
134
  dest.replace(auth.remove)
126
135
  end
127
136
  end
@@ -134,8 +143,8 @@ module IsoDoc
134
143
  end
135
144
  end
136
145
 
137
- def table_list_style1(t, num)
138
- (t.xpath(".//li") - t.xpath(".//ol//li | .//ul//li")).each do |t1|
146
+ def table_list_style1(tab, num)
147
+ (tab.xpath(".//li") - tab.xpath(".//ol//li | .//ul//li")).each do |t1|
139
148
  indent_list(t1, num)
140
149
  t1.xpath("./div | ./p").each { |p| indent_list(p, num) }
141
150
  (t1.xpath(".//ul") - t1.xpath(".//ul//ul | .//ol//ul")).each do |t2|
@@ -147,9 +156,9 @@ module IsoDoc
147
156
  end
148
157
  end
149
158
 
150
- def indent_list(li, num)
151
- li["style"] = (li["style"] ? li["style"] + ";" : "")
152
- li["style"] += "margin-left: #{num * 0.5}cm;text-indent: -0.5cm;"
159
+ def indent_list(list, num)
160
+ list["style"] = (list["style"] ? "#{list['style']};" : "")
161
+ list["style"] += "margin-left: #{num * 0.5}cm;text-indent: -0.5cm;"
153
162
  end
154
163
  end
155
164
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "1.3.9".freeze
3
+ VERSION = "1.3.10".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: 1.3.9
4
+ version: 1.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities