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.
- checksums.yaml +4 -4
- data/lib/asciidoctor/itu/cleanup.rb +64 -59
- data/lib/asciidoctor/itu/isodoc.rng +23 -9
- data/lib/isodoc/itu/itu.implementers-guide.xsl +294 -160
- data/lib/isodoc/itu/itu.in-force.xsl +294 -160
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +294 -160
- data/lib/isodoc/itu/itu.recommendation-supplement.xsl +294 -160
- data/lib/isodoc/itu/itu.recommendation.xsl +294 -160
- data/lib/isodoc/itu/itu.resolution.xsl +294 -160
- data/lib/isodoc/itu/itu.service-publication.xsl +294 -160
- data/lib/isodoc/itu/itu.technical-paper.xsl +294 -160
- data/lib/isodoc/itu/itu.technical-report.xsl +294 -160
- data/lib/isodoc/itu/metadata.rb +16 -16
- data/lib/isodoc/itu/presentation_xml_convert.rb +86 -75
- data/lib/isodoc/itu/word_cleanup.rb +30 -21
- data/lib/metanorma/itu/version.rb +1 -1
- metadata +2 -2
data/lib/isodoc/itu/metadata.rb
CHANGED
@@ -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
|
116
|
-
|
117
|
-
|
118
|
-
|
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)
|
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
|
192
|
-
:meeting_acronym, a
|
193
|
-
)
|
194
|
-
|
195
|
-
|
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 =
|
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[
|
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(
|
36
|
-
get_eref_linkend(
|
35
|
+
def eref1(elem)
|
36
|
+
get_eref_linkend(elem)
|
37
37
|
end
|
38
38
|
|
39
|
-
def note1(
|
40
|
-
return if
|
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
|
-
|
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")),
|
52
|
-
|
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(
|
60
|
+
def bibdata_i18n(bib)
|
57
61
|
super
|
58
|
-
bibdata_dates(
|
59
|
-
bibdata_title(
|
60
|
-
amendment_id(
|
62
|
+
bibdata_dates(bib)
|
63
|
+
bibdata_title(bib)
|
64
|
+
amendment_id(bib)
|
61
65
|
end
|
62
66
|
|
63
|
-
def bibdata_dates(
|
64
|
-
|
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(
|
72
|
-
case
|
73
|
-
when "service-publication" then bibdata_title_service_population(
|
74
|
-
when "resolution" then bibdata_title_resolution(
|
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(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
num =
|
85
|
-
text = @i18n.l10n("#{@i18n.get['doctype_dict']['resolution'].upcase}
|
86
|
-
|
87
|
-
ins
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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 =
|
97
|
-
ins.next = <<~
|
98
|
-
|
99
|
-
|
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(
|
104
|
-
|
105
|
-
|
106
|
-
d[
|
107
|
-
d[
|
108
|
-
d
|
109
|
-
|
110
|
-
|
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
|
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
|
124
|
-
d[2] = d[2].sub(/^0/, "") if d
|
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(
|
135
|
+
def amendment_id(bib)
|
130
136
|
%w(amendment corrigendum).each do |w|
|
131
|
-
if dn =
|
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(
|
145
|
-
return super unless
|
146
|
-
|
147
|
-
return
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
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}']")
|
98
|
-
|
99
|
-
|
105
|
+
docxml&.xpath("//div[@class = 'boilerplate-#{t}']")&.each do |d|
|
106
|
+
para = d&.at("./descendant::h1[2]") and
|
107
|
+
para.previous = "<p> </p><p> </p><p> </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
|
-
|
118
|
-
|
119
|
-
|
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> </p><p> </p><p> </p>"
|
133
|
+
auth << "<p> </p><p> </p><p> </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(
|
138
|
-
(
|
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(
|
151
|
-
|
152
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|