metanorma-bipm 1.0.6 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +12 -11
- data/.gitignore +4 -0
- data/.hound.yml +5 -0
- data/.rubocop.yml +10 -0
- data/Gemfile +2 -2
- data/Rakefile +2 -2
- data/lib/asciidoctor/bipm/biblio.rng +5 -6
- data/lib/asciidoctor/bipm/bipm.rng +3 -0
- data/lib/asciidoctor/bipm/converter.rb +72 -33
- data/lib/asciidoctor/bipm/isodoc.rng +321 -4
- data/lib/isodoc/bipm/base_convert.rb +25 -11
- data/lib/isodoc/bipm/bipm.brochure.xsl +726 -95
- data/lib/isodoc/bipm/bipm.guide.xsl +726 -95
- data/lib/isodoc/bipm/bipm.mise-en-pratique.xsl +726 -95
- data/lib/isodoc/bipm/bipm.rapport.xsl +726 -95
- data/lib/isodoc/bipm/html/html_bipm_titlepage.html +2 -0
- data/lib/isodoc/bipm/html/htmlstyle.css +7 -0
- data/lib/isodoc/bipm/i18n-en.yaml +11 -0
- data/lib/isodoc/bipm/i18n-fr.yaml +8 -0
- data/lib/isodoc/bipm/index.rb +32 -20
- data/lib/isodoc/bipm/init.rb +1 -2
- data/lib/isodoc/bipm/jcgm.standard.xsl +647 -119
- data/lib/isodoc/bipm/metadata.rb +15 -7
- data/lib/isodoc/bipm/pdf_convert.rb +12 -9
- data/lib/isodoc/bipm/presentation_xml_convert.rb +161 -44
- data/lib/isodoc/bipm/xref.rb +133 -36
- data/lib/metanorma-bipm.rb +4 -4
- data/lib/metanorma/bipm/version.rb +1 -1
- data/metanorma-bipm.gemspec +6 -5
- metadata +32 -15
data/lib/isodoc/bipm/metadata.rb
CHANGED
@@ -8,7 +8,8 @@ module IsoDoc
|
|
8
8
|
end
|
9
9
|
|
10
10
|
SI_ASPECT = %w(A_e_deltanu A_e cd_Kcd_h_deltanu cd_Kcd full K_k_deltanu
|
11
|
-
|
11
|
+
K_k kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA
|
12
|
+
s_deltanu).freeze
|
12
13
|
|
13
14
|
def initialize(lang, script, labels)
|
14
15
|
super
|
@@ -24,12 +25,12 @@ module IsoDoc
|
|
24
25
|
TITLE = "//bibdata/title".freeze
|
25
26
|
|
26
27
|
def title(isoxml, _out)
|
27
|
-
lang1, lang2
|
28
|
+
lang1, lang2 = @lang == "fr" ? %w(fr en) : %w(en fr)
|
28
29
|
set(:doctitle, @c.encode(isoxml&.at(
|
29
30
|
ns("#{TITLE}[@type='main'][@language='#{lang1}']"))&.text || ""))
|
30
31
|
set(:docsubtitle, @c.encode(isoxml&.at(
|
31
32
|
ns("#{TITLE}[@type='main'][@language='#{lang2}']"))&.text || ""))
|
32
|
-
%w(appendix annex part subtitle).each do |e|
|
33
|
+
%w(appendix annex part subtitle provenance).each do |e|
|
33
34
|
set("#{e}title".to_sym, @c.encode(isoxml&.at(
|
34
35
|
ns("#{TITLE}[@type='#{e}'][@language='#{lang1}']"))&.text || ""))
|
35
36
|
set("#{e}subtitle".to_sym, @c.encode(isoxml&.at(
|
@@ -40,9 +41,10 @@ module IsoDoc
|
|
40
41
|
def status_print(status)
|
41
42
|
return "Procès-Verbal" if status == "procès-verbal"
|
42
43
|
return "CIPM-MRA" if status == "cipm-mra"
|
44
|
+
|
43
45
|
status.split(/[- ]/).map.with_index do |s, i|
|
44
|
-
|
45
|
-
end.join(
|
46
|
+
%w(en de).include?(s) && i.positive? ? s : s.capitalize
|
47
|
+
end.join(" ")
|
46
48
|
end
|
47
49
|
|
48
50
|
def docid(isoxml, _out)
|
@@ -59,13 +61,19 @@ module IsoDoc
|
|
59
61
|
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/part"))
|
60
62
|
dn and set(:partid, @i18n.l10n("#{label1} #{dn&.text}"))
|
61
63
|
dn and set(:partid_alt, @i18n.l10n("#{label2} #{dn&.text}"))
|
62
|
-
set(:org_abbrev,
|
63
|
-
isoxml.at(ns("//bibdata/ext/editorialgroup/committee
|
64
|
+
set(:org_abbrev,
|
65
|
+
isoxml.at(ns("//bibdata/ext/editorialgroup/committee"\
|
66
|
+
"[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
|
64
67
|
end
|
65
68
|
|
66
69
|
def extract_person_names_affiliations(authors)
|
67
70
|
extract_person_affiliations(authors)
|
68
71
|
end
|
72
|
+
|
73
|
+
def bibdate(isoxml, _out)
|
74
|
+
pubdate = isoxml.at(ns("//bibdata/date[not(@format)][@type = 'published']"))
|
75
|
+
pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
71
79
|
end
|
@@ -4,7 +4,7 @@ module IsoDoc
|
|
4
4
|
module BIPM
|
5
5
|
# A {Converter} implementation that generates PDF HTML output, and a
|
6
6
|
# document schema encapsulation of the document for validation
|
7
|
-
class PdfConvert <
|
7
|
+
class PdfConvert < IsoDoc::XslfoPdfConvert
|
8
8
|
def initialize(options)
|
9
9
|
@libdir = File.dirname(__FILE__)
|
10
10
|
super
|
@@ -15,20 +15,23 @@ module IsoDoc
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def pdf_stylesheet(docxml)
|
18
|
-
|
18
|
+
docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))
|
19
|
+
&.value == "JCGM" and
|
20
|
+
return "jcgm.standard.xsl"
|
21
|
+
|
19
22
|
doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
|
20
|
-
doctype = "brochure" unless %w(guide mise-en-pratique rapport)
|
21
|
-
include? doctype
|
23
|
+
doctype = "brochure" unless %w(guide mise-en-pratique rapport)
|
24
|
+
.include? doctype
|
22
25
|
"bipm.#{doctype}.xsl"
|
23
26
|
end
|
24
27
|
|
25
28
|
def pdf_options(docxml)
|
29
|
+
n = configuration.document_namespace
|
30
|
+
q = "//m:bipm-standard/m:bibdata/m:language[@current = 'true']"
|
26
31
|
if docxml.root.name == "metanorma-collection" &&
|
27
|
-
docxml.at("
|
28
|
-
|
29
|
-
|
30
|
-
"m" => configuration.document_namespace)
|
31
|
-
"--split-by-language"
|
32
|
+
docxml.at("#{q}[. = 'fr']", "m" => n) &&
|
33
|
+
docxml.at("#{q}[. = 'en']", "m" => n)
|
34
|
+
"#{super} --split-by-language"
|
32
35
|
else
|
33
36
|
super
|
34
37
|
end
|
@@ -1,30 +1,70 @@
|
|
1
1
|
require "isodoc"
|
2
2
|
require "metanorma-generic"
|
3
|
+
require "metanorma-iso"
|
3
4
|
require_relative "init"
|
4
5
|
require_relative "index"
|
5
6
|
|
6
7
|
module IsoDoc
|
7
8
|
module BIPM
|
8
9
|
class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def convert1(docxml, filename, dir)
|
11
|
+
@jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/"\
|
12
|
+
"@acronym"))&.value == "JCGM"
|
13
|
+
@iso = IsoDoc::Iso::PresentationXMLConvert
|
14
|
+
.new({ language: @lang, script: @script })
|
15
|
+
i18n = @iso.i18n_init(@lang, @script, nil)
|
16
|
+
@iso.metadata_init(@lang, @script, i18n)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def eref_localities1(target, type, from, to, delim, n, lang = "en")
|
21
|
+
if @jcgm
|
22
|
+
@iso.eref_localities1(target, type, from, to, delim, n, lang)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def table1(elem)
|
29
|
+
return if labelled_ancestor(elem)
|
30
|
+
return if elem["unnumbered"]
|
31
|
+
|
32
|
+
n = @xrefs.anchor(elem["id"], :label, false)
|
33
|
+
prefix_name(elem, ".<tab/>",
|
34
|
+
l10n("#{@i18n.table.capitalize} #{n}"), "name")
|
35
|
+
end
|
36
|
+
|
37
|
+
def figure1(elem)
|
38
|
+
if @jcgm
|
39
|
+
@iso.xrefs = @xrefs
|
40
|
+
@iso.figure1(elem)
|
41
|
+
else super
|
42
|
+
end
|
14
43
|
end
|
15
44
|
|
16
|
-
def annex1(
|
17
|
-
return if
|
18
|
-
|
19
|
-
|
45
|
+
def annex1(elem)
|
46
|
+
return super if @jcgm
|
47
|
+
return if elem["unnumbered"] == "true"
|
48
|
+
|
49
|
+
lbl = @xrefs.anchor(elem["id"], :label)
|
50
|
+
if t = elem.at(ns("./title"))
|
20
51
|
t.children = "<strong>#{t.children.to_xml}</strong>"
|
21
52
|
end
|
22
|
-
prefix_name(
|
53
|
+
prefix_name(elem, ".<tab/>", lbl, "title")
|
23
54
|
end
|
24
55
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
56
|
+
def clause(docxml)
|
57
|
+
super
|
58
|
+
if @jcgm
|
59
|
+
docxml.xpath(ns("//preface/introduction[clause]")).each do |f|
|
60
|
+
clause1(f)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def clause1(elem)
|
66
|
+
return if elem["unnumbered"] == "true"
|
67
|
+
return if elem.at(("./ancestor::*[@unnumbered = 'true']"))
|
28
68
|
super
|
29
69
|
end
|
30
70
|
|
@@ -33,48 +73,64 @@ module IsoDoc
|
|
33
73
|
doccontrol docxml
|
34
74
|
end
|
35
75
|
|
36
|
-
def doccontrol
|
37
|
-
return unless
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
76
|
+
def doccontrol(doc)
|
77
|
+
return unless doc.at(ns("//bibdata/relation[@type = 'supersedes']"))
|
78
|
+
|
79
|
+
clause = <<~DOCCONTROL
|
80
|
+
<doccontrol>
|
81
|
+
<title>Document Control</title>
|
82
|
+
<table unnumbered="true"><tbody>
|
83
|
+
<tr><th>Authors:</th><td/><td>#{list_authors(doc)}</td></tr>
|
84
|
+
#{doccontrol_row1(doc)} #{doccontrol_row2(doc)} #{list_drafts(doc)}
|
85
|
+
</tbody></table></doccontrol>
|
86
|
+
DOCCONTROL
|
87
|
+
doc.root << clause
|
88
|
+
end
|
89
|
+
|
90
|
+
def doccontrol_row1(doc)
|
91
|
+
return "" if list_draft(doc, 1) == ["", ""] && list_cochairs(doc).empty?
|
92
|
+
|
93
|
+
<<~ROW
|
94
|
+
<tr>#{list_draft(doc, 1)&.map { |x| "<td>#{x}</td>" }&.join}
|
95
|
+
<td>#{list_cochairs(doc)}</td></tr>
|
96
|
+
ROW
|
97
|
+
end
|
98
|
+
|
99
|
+
def doccontrol_row2(docxml)
|
100
|
+
list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty? and
|
101
|
+
return ""
|
102
|
+
|
103
|
+
<<~ROW
|
104
|
+
<tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
|
105
|
+
<td>#{list_chairs(docxml)}</td></tr>
|
106
|
+
ROW
|
51
107
|
end
|
52
108
|
|
53
109
|
def list_drafts(xml)
|
54
110
|
ret = ""
|
55
111
|
i = 3
|
56
|
-
while
|
57
|
-
ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join
|
112
|
+
while list_draft(xml, i) != ["", ""]
|
113
|
+
ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join} "\
|
58
114
|
"<td/></tr>"
|
59
115
|
i += 1
|
60
116
|
end
|
61
117
|
ret
|
62
118
|
end
|
63
119
|
|
64
|
-
def list_draft(xml,
|
65
|
-
|
66
|
-
|
120
|
+
def list_draft(xml, idx)
|
121
|
+
d = xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{idx}]"\
|
122
|
+
"/bibitem")) or return ["", ""]
|
123
|
+
|
67
124
|
date = d&.at(ns("./date"))&.text
|
68
|
-
draft = d&.at(ns("./version/draft"))&.text and
|
69
|
-
|
70
|
-
edn
|
71
|
-
edn = "Edition #{edn}"
|
72
|
-
[date, [draft, edn].join(" ")]
|
125
|
+
draft = d&.at(ns("./version/draft"))&.text and draft = "Draft #{draft}"
|
126
|
+
edn = d&.at(ns("./edition"))&.text and edn = "Version #{edn}"
|
127
|
+
[[draft, edn].join(" "), date]
|
73
128
|
end
|
74
129
|
|
75
130
|
def list_authors(xml)
|
76
131
|
ret = list_people(
|
77
|
-
xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
|
132
|
+
xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
|
133
|
+
)
|
78
134
|
@i18n.multiple_and(ret, @i18n.get["and"])
|
79
135
|
end
|
80
136
|
|
@@ -84,16 +140,18 @@ module IsoDoc
|
|
84
140
|
|
85
141
|
def list_cochairs(xml)
|
86
142
|
ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
|
143
|
+
ret.empty? and return ""
|
87
144
|
role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
|
88
145
|
label = ret.size > 1 && role ? "#{role}s" : role
|
89
|
-
"#{label}: #{@i18n.multiple_and(ret, @i18n.get[
|
146
|
+
"#{label}: #{@i18n.multiple_and(ret, @i18n.get['and'])}"
|
90
147
|
end
|
91
148
|
|
92
149
|
def list_chairs(xml)
|
93
150
|
ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
|
151
|
+
ret.empty? and return ""
|
94
152
|
role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
|
95
153
|
label = ret.size > 1 && role ? "#{role}s" : role
|
96
|
-
"#{label}: #{@i18n.multiple_and(ret, @i18n.get[
|
154
|
+
"#{label}: #{@i18n.multiple_and(ret, @i18n.get['and'])}"
|
97
155
|
end
|
98
156
|
|
99
157
|
def list_people(xml, xpath)
|
@@ -110,11 +168,70 @@ module IsoDoc
|
|
110
168
|
end
|
111
169
|
|
112
170
|
def twitter_cldr_localiser_symbols
|
113
|
-
{ group: " ", fraction_group: " ",
|
171
|
+
{ group: " ", fraction_group: " ",
|
172
|
+
fraction_group_digits: 3 }
|
114
173
|
end
|
115
174
|
|
116
|
-
def mathml1(
|
117
|
-
localize_maths(
|
175
|
+
def mathml1(elem, locale)
|
176
|
+
localize_maths(elem, locale)
|
177
|
+
end
|
178
|
+
|
179
|
+
def bibdata_i18n(bibdata)
|
180
|
+
super
|
181
|
+
bibdata_dates(bibdata)
|
182
|
+
end
|
183
|
+
|
184
|
+
def bibdata_dates(bibdata)
|
185
|
+
pubdate = bibdata.at(ns("./date[not(@format)][@type = 'published']"))
|
186
|
+
return unless pubdate
|
187
|
+
|
188
|
+
meta = metadata_init(@lang, @script, @i18n)
|
189
|
+
pubdate.next = pubdate.dup
|
190
|
+
pubdate.next["format"] = "ddMMMyyyy"
|
191
|
+
pubdate.next.children = meta.monthyr(pubdate.text)
|
192
|
+
end
|
193
|
+
|
194
|
+
def eref(docxml)
|
195
|
+
super
|
196
|
+
jcgm_eref(docxml, "//eref")
|
197
|
+
end
|
198
|
+
|
199
|
+
def origin(docxml)
|
200
|
+
super
|
201
|
+
jcgm_eref(docxml, "//origin[not(termref)]")
|
202
|
+
end
|
203
|
+
|
204
|
+
def quotesource(docxml)
|
205
|
+
super
|
206
|
+
jcgm_eref(docxml, "//quote/source")
|
207
|
+
end
|
208
|
+
|
209
|
+
def jcgm_eref(docxml, xpath)
|
210
|
+
return unless @jcgm
|
211
|
+
|
212
|
+
docxml.xpath(ns(xpath)).each do |x|
|
213
|
+
extract_brackets(x)
|
214
|
+
end
|
215
|
+
# merge adjacent text nodes
|
216
|
+
docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
|
217
|
+
docxml.xpath(ns(xpath)).each do |x| # rubocop: disable Style/CombinableLoops
|
218
|
+
if x&.next&.text? && /^\],\s+\[$/.match?(x&.next&.text) &&
|
219
|
+
%w(eref origin source).include?(x&.next&.next&.name)
|
220
|
+
x.next.replace(", ")
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def extract_brackets(node)
|
226
|
+
start = node.at("./text()[1]")
|
227
|
+
finish = node.at("./text()[last()]")
|
228
|
+
if /^\[/.match?(start.text) && /\]$/.match?(finish.text)
|
229
|
+
start.replace(start.text[1..-1])
|
230
|
+
node.previous = "["
|
231
|
+
finish = node.at("./text()[last()]")
|
232
|
+
finish.replace(finish.text[0..-2])
|
233
|
+
node.next = "]"
|
234
|
+
end
|
118
235
|
end
|
119
236
|
|
120
237
|
include Init
|
data/lib/isodoc/bipm/xref.rb
CHANGED
@@ -5,11 +5,36 @@ module IsoDoc
|
|
5
5
|
|
6
6
|
class Xref < IsoDoc::Xref
|
7
7
|
def initialize(lang, script, klass, i18n, options = {})
|
8
|
+
@iso = IsoDoc::Iso::Xref.new(lang, script, klass, i18n, options)
|
8
9
|
super
|
9
10
|
end
|
10
11
|
|
12
|
+
def parse(docxml)
|
13
|
+
@jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/"\
|
14
|
+
"@acronym"))&.value == "JCGM"
|
15
|
+
@annexlbl =
|
16
|
+
if @jcgm then @labels["iso_annex"]
|
17
|
+
elsif docxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
|
18
|
+
@labels["appendix"]
|
19
|
+
else @labels["annex"]
|
20
|
+
end
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def wrap_brackets(txt)
|
25
|
+
return txt if /^\[.*\]$/.match?(txt)
|
26
|
+
|
27
|
+
"[#{txt}]"
|
28
|
+
end
|
29
|
+
|
30
|
+
def reference_names(ref)
|
31
|
+
super
|
32
|
+
@jcgm and
|
33
|
+
@anchors[ref["id"]][:xref] = wrap_brackets(@anchors[ref["id"]][:xref])
|
34
|
+
end
|
35
|
+
|
11
36
|
def clause_names(docxml, sect_num)
|
12
|
-
if
|
37
|
+
if @jcgm
|
13
38
|
clause_names_jcgm(docxml, sect_num)
|
14
39
|
else
|
15
40
|
clause_names_bipm(docxml, sect_num)
|
@@ -17,22 +42,22 @@ module IsoDoc
|
|
17
42
|
end
|
18
43
|
|
19
44
|
def clause_names_jcgm(docxml, sect_num)
|
20
|
-
docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')]
|
21
|
-
|
45
|
+
docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')]"\
|
46
|
+
"[not(descendant::terms)]")).each do |c|
|
22
47
|
section_names(c, sect_num, 1)
|
23
48
|
end
|
24
49
|
end
|
25
50
|
|
26
|
-
def clause_names_bipm(docxml,
|
51
|
+
def clause_names_bipm(docxml, _sect_num)
|
27
52
|
n = Counter.new
|
28
53
|
docxml.xpath(ns("//sections/clause[not(@unnumbered = 'true')] | "\
|
29
54
|
"//sections/terms[not(@unnumbered = 'true')] | "\
|
30
|
-
"//sections/definitions[not(@unnumbered = 'true')]"))
|
31
|
-
|
55
|
+
"//sections/definitions[not(@unnumbered = 'true')]"))
|
56
|
+
.each { |c| section_names(c, n, 1) }
|
32
57
|
docxml.xpath(ns("//sections/clause[@unnumbered = 'true'] | "\
|
33
58
|
"//sections/terms[@unnumbered = 'true'] | "\
|
34
|
-
"//sections/definitions[@unnumbered = 'true']"))
|
35
|
-
|
59
|
+
"//sections/definitions[@unnumbered = 'true']"))
|
60
|
+
.each { |c| unnumbered_section_names(c, 1) }
|
36
61
|
end
|
37
62
|
|
38
63
|
NUMBERED_SUBCLAUSES = "./clause[not(@unnumbered = 'true')] | "\
|
@@ -47,17 +72,24 @@ module IsoDoc
|
|
47
72
|
"./terms[@unnumbered = 'true'] | "\
|
48
73
|
"./definitions[@unnumbered = 'true']".freeze
|
49
74
|
|
75
|
+
def section_name_anchors(clause, num, lvl)
|
76
|
+
lbl = @jcgm ? "clause_jcgm" : "clause"
|
77
|
+
@anchors[clause["id"]] =
|
78
|
+
{ label: num.print, xref: l10n("#{@labels[lbl]} #{num.print}"),
|
79
|
+
level: lvl, type: "clause" }
|
80
|
+
end
|
81
|
+
|
50
82
|
def section_names(clause, num, lvl)
|
51
83
|
return num if clause.nil?
|
84
|
+
|
52
85
|
num.increment(clause)
|
53
|
-
@anchors[clause["id"]] =
|
54
|
-
level: lvl, type: "clause" }
|
86
|
+
@anchors[clause["id"]] = section_name_anchors(clause, num, lvl)
|
55
87
|
i = Counter.new
|
56
88
|
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
|
57
89
|
i.increment(c)
|
58
90
|
section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
|
59
91
|
end
|
60
|
-
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).
|
92
|
+
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
|
61
93
|
unnumbered_section_names1(c, lvl + 1)
|
62
94
|
end
|
63
95
|
num
|
@@ -65,29 +97,36 @@ module IsoDoc
|
|
65
97
|
|
66
98
|
def unnumbered_section_names(clause, lvl)
|
67
99
|
return if clause.nil?
|
68
|
-
|
69
|
-
|
70
|
-
clause
|
100
|
+
|
101
|
+
lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
|
102
|
+
@anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
|
103
|
+
level: lvl, type: "clause" }
|
104
|
+
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
71
105
|
unnumbered_section_names1(c, lvl + 1)
|
72
106
|
end
|
73
107
|
end
|
74
108
|
|
75
|
-
def
|
109
|
+
def section_name1_anchors(clause, num, level)
|
110
|
+
lbl = @jcgm ? "" : "#{@labels['subclause']} "
|
76
111
|
@anchors[clause["id"]] =
|
77
|
-
{ label: num, level: level, xref: l10n("#{
|
112
|
+
{ label: num, level: level, xref: l10n("#{lbl}#{num}"),
|
78
113
|
type: "clause" }
|
114
|
+
end
|
115
|
+
|
116
|
+
def section_names1(clause, num, level)
|
117
|
+
@anchors[clause["id"]] = section_name1_anchors(clause, num, level)
|
79
118
|
i = Counter.new
|
80
119
|
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
|
81
120
|
i.increment(c)
|
82
121
|
section_names1(c, "#{num}.#{i.print}", level + 1)
|
83
122
|
end
|
84
|
-
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).
|
123
|
+
clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
|
85
124
|
unnumbered_section_names1(c, lvl + 1)
|
86
125
|
end
|
87
126
|
end
|
88
127
|
|
89
128
|
def unnumbered_section_names1(clause, level)
|
90
|
-
lbl = clause&.at(ns("./title"))&.text || "[#{clause[
|
129
|
+
lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
|
91
130
|
@anchors[clause["id"]] =
|
92
131
|
{ label: lbl, xref: l10n(%{"#{lbl}"}), level: level, type: "clause" }
|
93
132
|
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
@@ -97,61 +136,119 @@ module IsoDoc
|
|
97
136
|
|
98
137
|
def back_anchor_names(docxml)
|
99
138
|
super
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
139
|
+
i = @jcgm ? Counter.new("@", skip_i: true) : Counter.new(0)
|
140
|
+
docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).each do |c|
|
141
|
+
i.increment(c)
|
142
|
+
annex_names(c, i.print)
|
143
|
+
end
|
144
|
+
docxml.xpath(ns("//annex[@unnumbered = 'true']"))
|
145
|
+
.each { |c| unnumbered_annex_names(c) }
|
104
146
|
docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
|
105
147
|
end
|
106
148
|
|
149
|
+
def annex_name_anchors(clause, num)
|
150
|
+
{ label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
|
151
|
+
xref: l10n("#{@annexlbl} #{num}"), level: 1 }
|
152
|
+
end
|
153
|
+
|
107
154
|
def annex_names(clause, num)
|
108
|
-
@anchors[clause["id"]] =
|
109
|
-
xref: l10n("#{@annexlbl} #{num}"), level: 1 }
|
155
|
+
@anchors[clause["id"]] = annex_name_anchors(clause, num)
|
110
156
|
if a = single_annex_special_section(clause)
|
111
|
-
annex_names1(a,
|
157
|
+
annex_names1(a, num.to_s, 1)
|
112
158
|
else
|
113
159
|
i = Counter.new
|
114
160
|
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
|
115
161
|
i.increment(c)
|
116
162
|
annex_names1(c, "#{num}.#{i.print}", 2)
|
117
163
|
end
|
118
|
-
clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
|
164
|
+
clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
|
165
|
+
.each { |c| unnumbered_annex_names1(c, 2) }
|
119
166
|
end
|
120
167
|
hierarchical_asset_names(clause, num)
|
121
168
|
end
|
122
169
|
|
170
|
+
def unnumbered_annex_anchors(lbl)
|
171
|
+
{ label: lbl, type: "clause", value: "",
|
172
|
+
xref: l10n(%{"#{lbl}"}), level: 1 }
|
173
|
+
end
|
174
|
+
|
123
175
|
def unnumbered_annex_names(clause)
|
124
|
-
lbl = clause&.at(ns("./title"))&.text || "[#{clause[
|
125
|
-
@anchors[clause["id"]] =
|
176
|
+
lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
|
177
|
+
@anchors[clause["id"]] = unnumbered_annex_anchors(lbl)
|
126
178
|
if a = single_annex_special_section(clause)
|
127
|
-
annex_names1(a,
|
179
|
+
annex_names1(a, num.to_s, 1)
|
128
180
|
else
|
129
|
-
clause.xpath(ns(SUBCLAUSES))
|
181
|
+
clause.xpath(ns(SUBCLAUSES))
|
182
|
+
.each { |c| unnumbered_annex_names1(c, 2) }
|
130
183
|
end
|
131
184
|
hierarchical_asset_names(clause, lbl)
|
132
185
|
end
|
133
186
|
|
187
|
+
def annex_names1_anchors(num, level)
|
188
|
+
lbl = @jcgm ? "" : "#{@annexlbl} "
|
189
|
+
{ label: num, xref: l10n("#{lbl}#{num}"),
|
190
|
+
level: level, type: "clause" }
|
191
|
+
end
|
192
|
+
|
134
193
|
def annex_names1(clause, num, level)
|
135
|
-
@anchors[clause["id"]] =
|
136
|
-
level: level, type: "clause" }
|
194
|
+
@anchors[clause["id"]] = annex_names1_anchors(num, level)
|
137
195
|
i = Counter.new
|
138
196
|
clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
|
139
197
|
i.increment(c)
|
140
198
|
annex_names1(c, "#{num}.#{i.print}", level + 1)
|
141
199
|
end
|
142
|
-
clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
|
200
|
+
clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
|
201
|
+
.each { |c| unnumbered_annex_names1(c, level + 1) }
|
143
202
|
end
|
144
203
|
|
145
204
|
def unnumbered_annex_names1(clause, level)
|
146
|
-
lbl = clause&.at(ns("./title"))&.text || "[#{clause[
|
205
|
+
lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
|
147
206
|
@anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
|
148
207
|
level: level, type: "clause" }
|
149
|
-
clause.xpath(ns(SUBCLAUSES))
|
208
|
+
clause.xpath(ns(SUBCLAUSES))
|
209
|
+
.each { |c| unnumbered_annex_names1(c, level + 1) }
|
150
210
|
end
|
151
211
|
|
152
|
-
def annex_name_lbl(
|
212
|
+
def annex_name_lbl(_clause, num)
|
153
213
|
l10n("<strong>#{@annexlbl} #{num}</strong>")
|
154
214
|
end
|
215
|
+
|
216
|
+
def sequential_formula_names(clause)
|
217
|
+
c = Counter.new
|
218
|
+
clause.xpath(ns(".//formula")).each do |t|
|
219
|
+
next if t["id"].nil? || t["id"].empty?
|
220
|
+
|
221
|
+
@anchors[t["id"]] = anchor_struct(
|
222
|
+
c.increment(t).print, nil,
|
223
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
224
|
+
"formula", t["unnumbered"]
|
225
|
+
)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def initial_anchor_names(doc)
|
230
|
+
super
|
231
|
+
if @jcgm
|
232
|
+
@iso.introduction_names(doc.at(ns("//introduction")))
|
233
|
+
@anchors.merge!(@iso.get)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def sequential_figure_names(clause)
|
238
|
+
if @jcgm
|
239
|
+
@iso.sequential_figure_names(clause)
|
240
|
+
@anchors.merge!(@iso.get)
|
241
|
+
else super
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def hierarchical_figure_names(clause, num)
|
246
|
+
if @jcgm
|
247
|
+
@iso.hierarchical_figure_names(clause, num)
|
248
|
+
@anchors.merge!(@iso.get)
|
249
|
+
else super
|
250
|
+
end
|
251
|
+
end
|
155
252
|
end
|
156
253
|
end
|
157
254
|
end
|