metanorma-itu 1.3.6 → 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/front.rb +38 -42
- data/lib/asciidoctor/itu/isodoc.rng +67 -16
- data/lib/asciidoctor/itu/reqt.rng +15 -4
- data/lib/isodoc/itu/itu.implementers-guide.xsl +1428 -643
- data/lib/isodoc/itu/itu.in-force.xsl +1428 -643
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +1428 -643
- data/lib/isodoc/itu/itu.recommendation-supplement.xsl +1428 -643
- data/lib/isodoc/itu/itu.recommendation.xsl +1428 -643
- data/lib/isodoc/itu/itu.resolution.xsl +1428 -643
- data/lib/isodoc/itu/itu.service-publication.xsl +7472 -0
- data/lib/isodoc/itu/itu.technical-paper.xsl +1428 -643
- data/lib/isodoc/itu/itu.technical-report.xsl +1428 -643
- data/lib/isodoc/itu/metadata.rb +23 -12
- data/lib/isodoc/itu/presentation_xml_convert.rb +86 -75
- data/lib/isodoc/itu/word_cleanup.rb +30 -21
- data/lib/isodoc/itu/xref.rb +42 -117
- data/lib/isodoc/itu/xref_section.rb +109 -0
- data/lib/metanorma/itu/processor.rb +1 -1
- data/lib/metanorma/itu/version.rb +1 -1
- metadata +4 -2
data/lib/isodoc/itu/metadata.rb
CHANGED
@@ -3,7 +3,6 @@ require "twitter_cldr"
|
|
3
3
|
|
4
4
|
module IsoDoc
|
5
5
|
module ITU
|
6
|
-
|
7
6
|
class Metadata < IsoDoc::Metadata
|
8
7
|
def initialize(lang, script, labels)
|
9
8
|
super
|
@@ -96,10 +95,10 @@ module IsoDoc
|
|
96
95
|
lbl = oblig == "informative" ? @labels["appendix"] : @labels["annex"]
|
97
96
|
dn and set(:annexid, @i18n.l10n("#{lbl} #{dn&.text}"))
|
98
97
|
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/amendment")) and
|
99
|
-
set(:amendmentid, @i18n.l10n("#{@labels[
|
98
|
+
set(:amendmentid, @i18n.l10n("#{@labels['amendment']} #{dn&.text}"))
|
100
99
|
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/corrigendum")) and
|
101
100
|
set(:corrigendumid,
|
102
|
-
@i18n.l10n("#{@labels[
|
101
|
+
@i18n.l10n("#{@labels['corrigendum']} #{dn&.text}"))
|
103
102
|
end
|
104
103
|
|
105
104
|
def unpublished(status)
|
@@ -113,14 +112,19 @@ module IsoDoc
|
|
113
112
|
pubdate and set(:pubdate_ddMMMyyyy, monthyr(pubdate.text))
|
114
113
|
pubdate = isoxml.at(ns("//bibdata/date[not(@format)][@type = 'published']")) ||
|
115
114
|
isoxml.at(ns("//bibdata/copyright/from"))
|
116
|
-
pubdate and
|
117
|
-
|
115
|
+
pubdate and
|
116
|
+
set(:placedate_year,
|
117
|
+
@labels["placedate"].sub(/%/,
|
118
|
+
pubdate.text.sub(
|
119
|
+
/^(\d\d\d\d).*$/, "\\1"
|
120
|
+
)))
|
118
121
|
end
|
119
122
|
|
120
123
|
def monthyr(isodate)
|
121
124
|
m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
|
122
125
|
return isodate unless m && m[:yr] && m[:mo]
|
123
|
-
|
126
|
+
|
127
|
+
"#{m[:mo]}/#{m[:yr]}"
|
124
128
|
end
|
125
129
|
|
126
130
|
def keywords(isoxml, _out)
|
@@ -149,7 +153,9 @@ module IsoDoc
|
|
149
153
|
def ddMMMYYYY(isodate)
|
150
154
|
m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)-(?<dd>\d\d)/.match isodate
|
151
155
|
return isodate unless m && m[:yr] && m[:mo] && m[:dd]
|
152
|
-
|
156
|
+
|
157
|
+
mmm = DateTime.parse(isodate).localize(@lang.to_sym)
|
158
|
+
.to_additional_s("MMM")
|
153
159
|
@i18n.l10n("#{m[:dd]} #{mmm} #{m[:yr]}")
|
154
160
|
end
|
155
161
|
|
@@ -184,20 +190,25 @@ module IsoDoc
|
|
184
190
|
set(:meeting, a)
|
185
191
|
set(:meeting_acronym, a)
|
186
192
|
end
|
187
|
-
a = isoxml&.at(ns("//bibdata/ext/meeting/@acronym"))&.text and
|
188
|
-
|
189
|
-
a = isoxml&.at(ns("//bibdata/ext/
|
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)
|
190
199
|
a = isoxml&.at(ns("//bibdata/ext/source"))&.text and set(:source, a)
|
191
200
|
meeting(isoxml)
|
192
201
|
end
|
193
202
|
|
194
203
|
def meeting(isoxml)
|
195
|
-
resolution =
|
204
|
+
resolution =
|
205
|
+
isoxml&.at(ns("//bibdata/ext/doctype"))&.text == "resolution"
|
196
206
|
if o = isoxml&.at(ns("//bibdata/ext/meeting-date/on"))&.text
|
197
207
|
set(:meeting_date, resolution ? ddMMMMYYYY(o, nil) : ddMMMYYYY(o))
|
198
208
|
elsif f = isoxml&.at(ns("//bibdata/ext/meeting-date/from"))&.text
|
199
209
|
t = isoxml&.at(ns("//bibdata/ext/meeting-date/to"))&.text
|
200
|
-
set(:meeting_date,
|
210
|
+
set(:meeting_date,
|
211
|
+
resolution ? ddMMMMYYYY(f, t) : "#{ddMMMYYYY(f)}/#{ddMMMYYYY(t)}")
|
201
212
|
end
|
202
213
|
end
|
203
214
|
end
|
@@ -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
|
data/lib/isodoc/itu/xref.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "isodoc"
|
2
2
|
require "fileutils"
|
3
|
+
require_relative "./xref_section"
|
3
4
|
|
4
5
|
module IsoDoc
|
5
6
|
module ITU
|
@@ -16,38 +17,15 @@ module IsoDoc
|
|
16
17
|
@hierarchical_assets = options[:hierarchical_assets]
|
17
18
|
end
|
18
19
|
|
19
|
-
def annex_name_lbl(clause, num)
|
20
|
-
lbl = clause["obligation"] == "informative" ? @labels["appendix"] : @labels["annex"]
|
21
|
-
@doctype == "resolution" ? l10n("#{lbl.upcase} #{num}") :
|
22
|
-
l10n("<strong>#{lbl} #{num}</strong>")
|
23
|
-
end
|
24
|
-
|
25
|
-
def annex_names(clause, num)
|
26
|
-
lbl = clause["obligation"] == "informative" ?
|
27
|
-
@labels["appendix"] : @labels["annex"]
|
28
|
-
@anchors[clause["id"]] =
|
29
|
-
{ label: annex_name_lbl(clause, num), type: "clause", xref: l10n("#{lbl} #{num}"), level: 1, value: num }
|
30
|
-
if a = single_annex_special_section(clause)
|
31
|
-
annex_names1(a, "#{num}", 1)
|
32
|
-
else
|
33
|
-
i = Counter.new
|
34
|
-
clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).
|
35
|
-
each do |c|
|
36
|
-
i.increment(c)
|
37
|
-
annex_names1(c, "#{num}.#{i.print}", 2)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
hierarchical_asset_names(clause, num)
|
41
|
-
end
|
42
|
-
|
43
20
|
def back_anchor_names(docxml)
|
44
21
|
super
|
45
|
-
if annexid = docxml
|
22
|
+
if annexid = docxml
|
23
|
+
&.at(ns("//bibdata/ext/structuredidentifier/annexid"))&.text
|
46
24
|
docxml.xpath(ns("//annex")).each { |c| annex_names(c, annexid) }
|
47
25
|
else
|
48
26
|
i = Counter.new(0, numerals: :roman)
|
49
27
|
docxml.xpath(ns("//annex[@obligation = 'informative']"))
|
50
|
-
.
|
28
|
+
.each do |c|
|
51
29
|
i.increment(c)
|
52
30
|
annex_names(c, i.print.upcase)
|
53
31
|
end
|
@@ -60,35 +38,25 @@ module IsoDoc
|
|
60
38
|
end
|
61
39
|
end
|
62
40
|
|
63
|
-
def
|
64
|
-
@
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
41
|
+
def initial_anchor_names(doc)
|
42
|
+
@doctype = doc&.at(ns("//bibdata/ext/doctype"))&.text
|
43
|
+
doc.xpath(ns("//boilerplate//clause")).each { |c| preface_names(c) }
|
44
|
+
doc.xpath("//xmlns:preface/child::*").each { |c| preface_names(c) }
|
45
|
+
if @hierarchical_assets
|
46
|
+
hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"),
|
47
|
+
"Preface")
|
48
|
+
else
|
49
|
+
sequential_asset_names(doc.xpath("//xmlns:preface/child::*"))
|
72
50
|
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def initial_anchor_names(d)
|
76
|
-
@doctype = d&.at(ns("//bibdata/ext/doctype"))&.text
|
77
|
-
d.xpath(ns("//boilerplate//clause")).each { |c| preface_names(c) }
|
78
|
-
d.xpath("//xmlns:preface/child::*").each { |c| preface_names(c) }
|
79
|
-
@hierarchical_assets ?
|
80
|
-
hierarchical_asset_names(d.xpath("//xmlns:preface/child::*"),
|
81
|
-
"Preface") :
|
82
|
-
sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
|
83
51
|
n = Counter.new
|
84
|
-
n = section_names(
|
85
|
-
n = section_names(
|
86
|
-
n = section_names(
|
87
|
-
n = section_names(
|
88
|
-
clause_names(
|
89
|
-
middle_section_asset_names(
|
90
|
-
termnote_anchor_names(
|
91
|
-
termexample_anchor_names(
|
52
|
+
n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
|
53
|
+
n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
|
54
|
+
n = section_names(doc.at(ns("//sections/terms | //sections/clause[descendant::terms]")), n, 1)
|
55
|
+
n = section_names(doc.at(ns("//sections/definitions")), n, 1)
|
56
|
+
clause_names(doc, n)
|
57
|
+
middle_section_asset_names(doc)
|
58
|
+
termnote_anchor_names(doc)
|
59
|
+
termexample_anchor_names(doc)
|
92
60
|
end
|
93
61
|
|
94
62
|
def middle_sections
|
@@ -99,9 +67,10 @@ module IsoDoc
|
|
99
67
|
"//sections/definitions | //clause[parent::sections]"
|
100
68
|
end
|
101
69
|
|
102
|
-
def middle_section_asset_names(
|
70
|
+
def middle_section_asset_names(doc)
|
103
71
|
return super unless @hierarchical_assets
|
104
|
-
|
72
|
+
|
73
|
+
doc.xpath(ns(middle_sections)).each do |c|
|
105
74
|
hierarchical_asset_names(c, @anchors[c["id"]][:label])
|
106
75
|
end
|
107
76
|
end
|
@@ -115,9 +84,11 @@ module IsoDoc
|
|
115
84
|
j = 0
|
116
85
|
c.increment(t)
|
117
86
|
end
|
118
|
-
label = c.print + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr
|
87
|
+
label = c.print + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr}")
|
119
88
|
next if t["id"].nil? || t["id"].empty?
|
120
|
-
|
89
|
+
|
90
|
+
@anchors[t["id"]] =
|
91
|
+
anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"])
|
121
92
|
end
|
122
93
|
end
|
123
94
|
|
@@ -130,9 +101,11 @@ module IsoDoc
|
|
130
101
|
j = 0
|
131
102
|
c.increment(t)
|
132
103
|
end
|
133
|
-
label = "#{num}#{hiersep}#{c.print}" + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr
|
104
|
+
label = "#{num}#{hiersep}#{c.print}" + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr}")
|
134
105
|
next if t["id"].nil? || t["id"].empty?
|
135
|
-
|
106
|
+
|
107
|
+
@anchors[t["id"]] =
|
108
|
+
anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"])
|
136
109
|
end
|
137
110
|
end
|
138
111
|
|
@@ -150,15 +123,19 @@ module IsoDoc
|
|
150
123
|
c = Counter.new
|
151
124
|
clause.xpath(ns(".//formula")).each do |t|
|
152
125
|
next if t["id"].nil? || t["id"].empty?
|
126
|
+
|
153
127
|
@anchors[t["id"]] = anchor_struct(
|
154
128
|
"#{num}-#{c.increment(t).print}", nil,
|
155
|
-
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
129
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
130
|
+
"formula", t["unnumbered"]
|
131
|
+
)
|
156
132
|
end
|
157
133
|
end
|
158
134
|
|
159
135
|
def reference_names(ref)
|
160
136
|
super
|
161
|
-
@anchors[ref["id"]] =
|
137
|
+
@anchors[ref["id"]] =
|
138
|
+
{ xref: @anchors[ref["id"]][:xref].sub(/^\[/, "").sub(/\]$/, "") }
|
162
139
|
end
|
163
140
|
|
164
141
|
def termnote_anchor_names(docxml)
|
@@ -167,67 +144,15 @@ module IsoDoc
|
|
167
144
|
notes = t.xpath(ns(".//termnote"))
|
168
145
|
notes.each do |n|
|
169
146
|
return if n["id"].nil? || n["id"].empty?
|
147
|
+
|
170
148
|
idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
|
171
|
-
@anchors[n["id"]] =
|
149
|
+
@anchors[n["id"]] =
|
172
150
|
{ label: termnote_label(idx).strip, type: "termnote", value: idx,
|
173
|
-
xref: l10n("#{anchor(t['id'], :xref)},
|
151
|
+
xref: l10n("#{anchor(t['id'], :xref)},
|
152
|
+
#{@labels['note_xref']} #{c.print}") }
|
174
153
|
end
|
175
154
|
end
|
176
155
|
end
|
177
|
-
|
178
|
-
def clause_names(docxml, sect_num)
|
179
|
-
docxml.xpath(ns("//sections/clause[not(@unnumbered = 'true')][not(@type = 'scope')][not(descendant::terms)]")).
|
180
|
-
each do |c|
|
181
|
-
section_names(c, sect_num, 1)
|
182
|
-
end
|
183
|
-
docxml.xpath(ns("//sections/clause[@unnumbered = 'true']")).each do |c|
|
184
|
-
unnumbered_section_names(c, 1)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def section_names(clause, num, lvl)
|
189
|
-
return num if clause.nil?
|
190
|
-
num.increment(clause)
|
191
|
-
lbl = @doctype == "resolution" ? @labels["section"] : @labels["clause"]
|
192
|
-
@anchors[clause["id"]] =
|
193
|
-
{ label: num.print, xref: l10n("#{lbl} #{num.print}"), level: lvl, type: "clause" }
|
194
|
-
i = Counter.new()
|
195
|
-
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
196
|
-
i.increment(c)
|
197
|
-
section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
|
198
|
-
end
|
199
|
-
num
|
200
|
-
end
|
201
|
-
|
202
|
-
def section_names1(clause, num, level)
|
203
|
-
@anchors[clause["id"]] =
|
204
|
-
{ label: num, level: level,
|
205
|
-
xref: @doctype == "resolution" ? num : l10n("#{@labels["clause"]} #{num}") }
|
206
|
-
i = Counter.new()
|
207
|
-
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
208
|
-
i.increment(c)
|
209
|
-
section_names1(c, "#{num}.#{i.print}", level + 1)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def unnumbered_section_names(clause, lvl)
|
214
|
-
return if clause.nil?
|
215
|
-
lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
|
216
|
-
@anchors[clause["id"]] =
|
217
|
-
{ label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" }
|
218
|
-
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
219
|
-
unnumbered_section_names1(c, lvl + 1)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
def unnumbered_section_names1(clause, level)
|
224
|
-
lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
|
225
|
-
@anchors[clause["id"]] =
|
226
|
-
{ label: lbl, xref: l10n(%{"#{lbl}"}), level: level, type: "clause" }
|
227
|
-
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
228
|
-
unnumbered_section_names1(c, level + 1)
|
229
|
-
end
|
230
|
-
end
|
231
156
|
end
|
232
157
|
end
|
233
158
|
end
|