metanorma-itu 2.4.2 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/itu/base_convert.rb +44 -21
- data/lib/isodoc/itu/html/html_itu_titlepage.html +7 -4
- data/lib/isodoc/itu/html/word_itu_titlepage.html +17 -34
- data/lib/isodoc/itu/i18n-ar.yaml +3 -0
- data/lib/isodoc/itu/i18n-de.yaml +3 -0
- data/lib/isodoc/itu/i18n-en.yaml +3 -0
- data/lib/isodoc/itu/i18n-es.yaml +3 -0
- data/lib/isodoc/itu/i18n-fr.yaml +3 -0
- data/lib/isodoc/itu/i18n-ru.yaml +3 -0
- data/lib/isodoc/itu/i18n-zh-Hans.yaml +3 -0
- data/lib/isodoc/itu/init.rb +5 -0
- data/lib/isodoc/itu/itu.implementers-guide.xsl +1447 -708
- data/lib/isodoc/itu/itu.in-force.xsl +1447 -708
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +1447 -708
- data/lib/isodoc/itu/itu.recommendation-supplement.xsl +1447 -708
- data/lib/isodoc/itu/itu.recommendation.xsl +1447 -708
- data/lib/isodoc/itu/itu.resolution.xsl +1447 -708
- data/lib/isodoc/itu/itu.service-publication.xsl +1447 -708
- data/lib/isodoc/itu/itu.technical-paper.xsl +1447 -708
- data/lib/isodoc/itu/itu.technical-report.xsl +1447 -708
- data/lib/isodoc/itu/metadata.rb +4 -0
- data/lib/isodoc/itu/presentation_ref.rb +97 -0
- data/lib/isodoc/itu/presentation_xml_convert.rb +49 -95
- data/lib/metanorma/itu/biblio.rng +28 -25
- data/lib/metanorma/itu/cleanup.rb +21 -143
- data/lib/metanorma/itu/cleanup_section.rb +150 -0
- data/lib/metanorma/itu/converter.rb +11 -7
- data/lib/metanorma/itu/front.rb +36 -22
- data/lib/metanorma/itu/version.rb +1 -1
- data/metanorma-itu.gemspec +2 -1
- metadata +20 -4
data/lib/isodoc/itu/metadata.rb
CHANGED
@@ -31,6 +31,8 @@ module IsoDoc
|
|
31
31
|
series1: "//bibdata/series[@type='secondary']/title",
|
32
32
|
series2: "//bibdata/series[@type='tertiary']/title",
|
33
33
|
annextitle: "//bibdata/title[@type='annex']",
|
34
|
+
collectiontitle: "//bibdata/title[@type='collection']",
|
35
|
+
slogantitle: "//bibdata/title[@type='slogan']",
|
34
36
|
positiontitle: "//bibdata/title[@type='position-sp']" }.each do |k, v|
|
35
37
|
titleset(isoxml, k, v)
|
36
38
|
end
|
@@ -51,6 +53,8 @@ module IsoDoc
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def author(xml, _out)
|
56
|
+
sector = xml.at(ns("//bibdata/ext/editorialgroup/sector"))
|
57
|
+
set(:sector, sector.text) if sector
|
54
58
|
bureau = xml.at(ns("//bibdata/ext/editorialgroup/bureau"))
|
55
59
|
set(:bureau, bureau.text) if bureau
|
56
60
|
tc = xml.at(ns("//bibdata/ext/editorialgroup/committee"))
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require_relative "init"
|
2
|
+
require "roman-numerals"
|
3
|
+
require "isodoc"
|
4
|
+
require_relative "../../relaton/render/general"
|
5
|
+
require_relative "presentation_bibdata"
|
6
|
+
require_relative "presentation_preface"
|
7
|
+
|
8
|
+
module IsoDoc
|
9
|
+
module ITU
|
10
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
11
|
+
def bibrender_formattedref(formattedref, _xml)
|
12
|
+
formattedref << "." unless /\.$/.match?(formattedref.text)
|
13
|
+
id = reference_format_start(formattedref.parent) and
|
14
|
+
formattedref.children.first.previous = id
|
15
|
+
end
|
16
|
+
|
17
|
+
def bibrender_relaton(xml, renderings)
|
18
|
+
f = renderings[xml["id"]][:formattedref]
|
19
|
+
ids = reference_format_start(xml)
|
20
|
+
f &&= "<formattedref>#{ids}#{f}</formattedref>"
|
21
|
+
# retain date in order to generate reference tag
|
22
|
+
keep = "./docidentifier | ./uri | ./note | ./date | ./biblio-tag"
|
23
|
+
xml.children = "#{f}#{xml.xpath(ns(keep)).to_xml}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def multi_bibitem_ref_code(bib)
|
27
|
+
id = pref_ref_code_parse(bib)
|
28
|
+
id.nil? and return []
|
29
|
+
id.sort_by { |i| /^ITU/.match?(i) ? 0 : 1 }
|
30
|
+
end
|
31
|
+
|
32
|
+
def render_multi_identifiers(ids, bib)
|
33
|
+
ids.map do |id|
|
34
|
+
if /^ITU/.match?(id) then doctype_title(id, bib)
|
35
|
+
else
|
36
|
+
id.sub(/^\[/, "").sub(/\]$/, "")
|
37
|
+
end
|
38
|
+
end.join(" | ")
|
39
|
+
end
|
40
|
+
|
41
|
+
def doctype_title(id, bib)
|
42
|
+
type = bib.at(ns("./ext/doctype"))&.text || "recommendation"
|
43
|
+
if type == "recommendation" &&
|
44
|
+
/^(?<prefix>ITU-[A-Z][ ][A-Z])[ .-]Sup[a-z]*\.[ ]?(?<num>\d+)$/ =~ id
|
45
|
+
"#{prefix}-series Recommendations – Supplement #{num}"
|
46
|
+
else
|
47
|
+
d = id.sub(/^\[/, "").sub(/\]$/, "")
|
48
|
+
"#{titlecase(type)} #{d}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def reference_format_start(bib)
|
53
|
+
id = multi_bibitem_ref_code(bib)
|
54
|
+
id1 = render_multi_identifiers(id, bib)
|
55
|
+
out = id1
|
56
|
+
date = bib.at(ns("./date[@type = 'published']/on | " \
|
57
|
+
"./date[@type = 'published']/from")) and
|
58
|
+
out << " (#{date.text.sub(/-.*$/, '')})"
|
59
|
+
out += ", " if date || !id1.empty?
|
60
|
+
out
|
61
|
+
end
|
62
|
+
|
63
|
+
def bibliography_bibitem_number1(bib, idx)
|
64
|
+
mn = bib.at(ns(".//docidentifier[@type = 'metanorma']")) and
|
65
|
+
/^\[?\d+\]?$/.match?(mn.text) and
|
66
|
+
mn["type"] = "metanorma-ordinal"
|
67
|
+
if (mn = bib.at(ns(".//docidentifier[@type = 'metanorma-ordinal']"))) &&
|
68
|
+
!bibliography_bibitem_number_skip(bib)
|
69
|
+
idx += 1
|
70
|
+
mn.children = "[#{idx}]"
|
71
|
+
end
|
72
|
+
idx
|
73
|
+
end
|
74
|
+
|
75
|
+
def bibliography_bibitem_number_skip(bibitem)
|
76
|
+
@xrefs.klass.implicit_reference(bibitem) ||
|
77
|
+
bibitem["hidden"] == "true" || bibitem.parent["hidden"] == "true"
|
78
|
+
end
|
79
|
+
|
80
|
+
def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
|
81
|
+
ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
|
82
|
+
/^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
|
83
|
+
ret += datefn
|
84
|
+
ret.empty? and return ret
|
85
|
+
ret.gsub("-", "‑").gsub(/ /, " ")
|
86
|
+
end
|
87
|
+
|
88
|
+
def biblio_ref_entry_code(_ordinal, idents, _id, _standard, datefn, _bib)
|
89
|
+
ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
|
90
|
+
/^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
|
91
|
+
ret += datefn
|
92
|
+
ret.empty? and return ret
|
93
|
+
ret.gsub("-", "‑").gsub(/ /, " ")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -4,6 +4,18 @@ require "isodoc"
|
|
4
4
|
require_relative "../../relaton/render/general"
|
5
5
|
require_relative "presentation_bibdata"
|
6
6
|
require_relative "presentation_preface"
|
7
|
+
require_relative "presentation_ref"
|
8
|
+
|
9
|
+
module Nokogiri
|
10
|
+
module XML
|
11
|
+
class Node
|
12
|
+
def traverse_topdown(&block)
|
13
|
+
yield(self)
|
14
|
+
children.each { |j| j.traverse_topdown(&block) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
7
19
|
|
8
20
|
module IsoDoc
|
9
21
|
module ITU
|
@@ -39,6 +51,25 @@ module IsoDoc
|
|
39
51
|
super
|
40
52
|
end
|
41
53
|
|
54
|
+
def table1(elem)
|
55
|
+
elem.xpath(ns("./name | ./thead/tr/th")).each do |n|
|
56
|
+
capitalise_unless_text_transform(n)
|
57
|
+
end
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
def capitalise_unless_text_transform(elem)
|
62
|
+
css = nil
|
63
|
+
elem.traverse_topdown do |n|
|
64
|
+
n.name == "span" && /text-transform:/.match?(n["style"]) and
|
65
|
+
css = n
|
66
|
+
n.text? && /\S/.match?(n.text) or next
|
67
|
+
css && n.ancestors.include?(css) or
|
68
|
+
n.replace(::Metanorma::Utils.strict_capitalize_first(n.text))
|
69
|
+
break
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
42
73
|
def get_eref_linkend(node)
|
43
74
|
non_locality_elems(node).select do |c|
|
44
75
|
!c.text? || /\S/.match(c)
|
@@ -52,72 +83,10 @@ module IsoDoc
|
|
52
83
|
node.add_child(link)
|
53
84
|
end
|
54
85
|
|
55
|
-
def bibrenderer
|
56
|
-
::Relaton::Render::ITU::General.new(language: @lang)
|
57
|
-
end
|
58
|
-
|
59
|
-
def bibrender_formattedref(formattedref, _xml)
|
60
|
-
formattedref << "." unless /\.$/.match?(formattedref.text)
|
61
|
-
id = reference_format_start(formattedref.parent) and
|
62
|
-
formattedref.children.first.previous = id
|
63
|
-
end
|
64
|
-
|
65
|
-
def bibrender_relaton(xml, renderings)
|
66
|
-
f = renderings[xml["id"]][:formattedref]
|
67
|
-
ids = reference_format_start(xml)
|
68
|
-
f &&= "<formattedref>#{ids}#{f}</formattedref>"
|
69
|
-
# retain date in order to generate reference tag
|
70
|
-
keep = "./docidentifier | ./uri | ./note | ./date | ./biblio-tag"
|
71
|
-
xml.children = "#{f}#{xml.xpath(ns(keep)).to_xml}"
|
72
|
-
end
|
73
|
-
|
74
|
-
def multi_bibitem_ref_code(bib)
|
75
|
-
skip = IsoDoc::Function::References::SKIP_DOCID
|
76
|
-
skip1 = "@type = 'metanorma' or @type = 'metanorma-ordinal'"
|
77
|
-
prim = "[@primary = 'true']"
|
78
|
-
id = bib.xpath(ns("./docidentifier#{prim}[not(#{skip} or #{skip1})]"))
|
79
|
-
id.empty? and id = bib.xpath(ns("./docidentifier#{prim}[not(#{skip1})]"))
|
80
|
-
id.empty? and id = bib.xpath(ns("./docidentifier[not(#{skip} or #{skip1})]"))
|
81
|
-
id.empty? and id = bib.xpath(ns("./docidentifier[not(#{skip1})]"))
|
82
|
-
id.empty? and return id
|
83
|
-
id.sort_by { |i| i["type"] == "ITU" ? 0 : 1 }
|
84
|
-
end
|
85
|
-
|
86
|
-
def render_multi_identifiers(ids)
|
87
|
-
ids.map do |id|
|
88
|
-
if id["type"] == "ITU" then doctype_title(id)
|
89
|
-
else
|
90
|
-
docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
|
91
|
-
end
|
92
|
-
end.join(" | ")
|
93
|
-
end
|
94
|
-
|
95
|
-
def reference_format_start(bib)
|
96
|
-
id = multi_bibitem_ref_code(bib)
|
97
|
-
id1 = render_multi_identifiers(id)
|
98
|
-
out = id1
|
99
|
-
date = bib.at(ns("./date[@type = 'published']/on | " \
|
100
|
-
"./date[@type = 'published']/from")) and
|
101
|
-
out << " (#{date.text.sub(/-.*$/, '')})"
|
102
|
-
out += ", " if date || !id1.empty?
|
103
|
-
out
|
104
|
-
end
|
105
|
-
|
106
86
|
def titlecase(str)
|
107
87
|
str.gsub(/ |_|-/, " ").split(/ /).map(&:capitalize).join(" ")
|
108
88
|
end
|
109
89
|
|
110
|
-
def doctype_title(id)
|
111
|
-
type = id.parent&.at(ns("./ext/doctype"))&.text || "recommendation"
|
112
|
-
if type == "recommendation" &&
|
113
|
-
/^(?<prefix>ITU-[A-Z][ ][A-Z])[ .-]Sup[a-z]*\.[ ]?(?<num>\d+)$/ =~ id.text
|
114
|
-
"#{prefix}-series Recommendations – Supplement #{num}"
|
115
|
-
else
|
116
|
-
d = docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
|
117
|
-
"#{titlecase(type)} #{d}"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
90
|
def twitter_cldr_localiser_symbols
|
122
91
|
{ group: "'" }
|
123
92
|
end
|
@@ -165,39 +134,6 @@ module IsoDoc
|
|
165
134
|
super
|
166
135
|
end
|
167
136
|
|
168
|
-
def bibliography_bibitem_number1(bib, idx)
|
169
|
-
mn = bib.at(ns(".//docidentifier[@type = 'metanorma']")) and
|
170
|
-
/^\[?\d+\]?$/.match?(mn.text) and
|
171
|
-
mn["type"] = "metanorma-ordinal"
|
172
|
-
if (mn = bib.at(ns(".//docidentifier[@type = 'metanorma-ordinal']"))) &&
|
173
|
-
!bibliography_bibitem_number_skip(bib)
|
174
|
-
idx += 1
|
175
|
-
mn.children = "[#{idx}]"
|
176
|
-
end
|
177
|
-
idx
|
178
|
-
end
|
179
|
-
|
180
|
-
def bibliography_bibitem_number_skip(bibitem)
|
181
|
-
@xrefs.klass.implicit_reference(bibitem) ||
|
182
|
-
bibitem["hidden"] == "true" || bibitem.parent["hidden"] == "true"
|
183
|
-
end
|
184
|
-
|
185
|
-
def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
|
186
|
-
ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
|
187
|
-
/^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
|
188
|
-
ret += datefn
|
189
|
-
ret.empty? and return ret
|
190
|
-
ret.gsub("-", "‑").gsub(/ /, " ")
|
191
|
-
end
|
192
|
-
|
193
|
-
def biblio_ref_entry_code(_ordinal, idents, _id, _standard, datefn, _bib)
|
194
|
-
ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
|
195
|
-
/^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
|
196
|
-
ret += datefn
|
197
|
-
ret.empty? and return ret
|
198
|
-
ret.gsub("-", "‑").gsub(/ /, " ")
|
199
|
-
end
|
200
|
-
|
201
137
|
def toc_title(docxml)
|
202
138
|
@doctype == "resolution" and return
|
203
139
|
super
|
@@ -261,6 +197,24 @@ module IsoDoc
|
|
261
197
|
ret
|
262
198
|
end
|
263
199
|
|
200
|
+
def block(docxml)
|
201
|
+
super
|
202
|
+
dl docxml
|
203
|
+
end
|
204
|
+
|
205
|
+
def dl(xml)
|
206
|
+
(xml.xpath(ns("//dl")) -
|
207
|
+
xml.xpath(ns("//table//dl | //figure//dl | //formula//dl")))
|
208
|
+
.each do |d|
|
209
|
+
dl1(d)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def dl1(dlist)
|
214
|
+
ins = dlist.at(ns("./dt"))
|
215
|
+
ins.previous = '<colgroup><col width="20%"/><col width="80%"/></colgroup>'
|
216
|
+
end
|
217
|
+
|
264
218
|
include Init
|
265
219
|
end
|
266
220
|
end
|
@@ -338,29 +338,32 @@
|
|
338
338
|
</define>
|
339
339
|
<define name="organization">
|
340
340
|
<element name="organization">
|
341
|
-
<
|
342
|
-
<ref name="orgname"/>
|
343
|
-
</oneOrMore>
|
344
|
-
<zeroOrMore>
|
345
|
-
<ref name="subdivision"/>
|
346
|
-
</zeroOrMore>
|
347
|
-
<optional>
|
348
|
-
<ref name="abbreviation"/>
|
349
|
-
</optional>
|
350
|
-
<zeroOrMore>
|
351
|
-
<ref name="uri"/>
|
352
|
-
</zeroOrMore>
|
353
|
-
<zeroOrMore>
|
354
|
-
<ref name="org-identifier"/>
|
355
|
-
</zeroOrMore>
|
356
|
-
<zeroOrMore>
|
357
|
-
<ref name="contact"/>
|
358
|
-
</zeroOrMore>
|
359
|
-
<optional>
|
360
|
-
<ref name="logo"/>
|
361
|
-
</optional>
|
341
|
+
<ref name="OrganizationType"/>
|
362
342
|
</element>
|
363
343
|
</define>
|
344
|
+
<define name="OrganizationType">
|
345
|
+
<oneOrMore>
|
346
|
+
<ref name="orgname"/>
|
347
|
+
</oneOrMore>
|
348
|
+
<zeroOrMore>
|
349
|
+
<ref name="subdivision"/>
|
350
|
+
</zeroOrMore>
|
351
|
+
<optional>
|
352
|
+
<ref name="abbreviation"/>
|
353
|
+
</optional>
|
354
|
+
<zeroOrMore>
|
355
|
+
<ref name="uri"/>
|
356
|
+
</zeroOrMore>
|
357
|
+
<zeroOrMore>
|
358
|
+
<ref name="org-identifier"/>
|
359
|
+
</zeroOrMore>
|
360
|
+
<zeroOrMore>
|
361
|
+
<ref name="contact"/>
|
362
|
+
</zeroOrMore>
|
363
|
+
<optional>
|
364
|
+
<ref name="logo"/>
|
365
|
+
</optional>
|
366
|
+
</define>
|
364
367
|
<define name="orgname">
|
365
368
|
<element name="name">
|
366
369
|
<choice>
|
@@ -371,10 +374,10 @@
|
|
371
374
|
</define>
|
372
375
|
<define name="subdivision">
|
373
376
|
<element name="subdivision">
|
374
|
-
<
|
375
|
-
<
|
376
|
-
|
377
|
-
|
377
|
+
<optional>
|
378
|
+
<attribute name="type"/>
|
379
|
+
</optional>
|
380
|
+
<ref name="OrganizationType"/>
|
378
381
|
</element>
|
379
382
|
</define>
|
380
383
|
<define name="logo">
|
@@ -1,21 +1,8 @@
|
|
1
|
+
require_relative "cleanup_section"
|
2
|
+
|
1
3
|
module Metanorma
|
2
4
|
module ITU
|
3
5
|
class Converter < Standoc::Converter
|
4
|
-
def sections_cleanup(xml)
|
5
|
-
super
|
6
|
-
insert_missing_sections(xml) unless @no_insert_missing_sections
|
7
|
-
insert_empty_clauses(xml)
|
8
|
-
resolution_inline_header(xml)
|
9
|
-
end
|
10
|
-
|
11
|
-
def resolution_inline_header(xml)
|
12
|
-
@doctype == "resolution" or return
|
13
|
-
xml.xpath("//clause//clause").each do |c|
|
14
|
-
(title = c.at("./title")) && !title.text&.empty? and next
|
15
|
-
c["inline-header"] = true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
6
|
def table_cleanup(xmldoc)
|
20
7
|
super
|
21
8
|
xmldoc.xpath("//thead/tr[1]/th | //thead/tr[1]/td").each do |t|
|
@@ -24,84 +11,13 @@ module Metanorma
|
|
24
11
|
end
|
25
12
|
end
|
26
13
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
insert_norm_ref(xml)
|
32
|
-
insert_terms(xml)
|
33
|
-
insert_symbols(xml)
|
34
|
-
insert_conventions(xml)
|
35
|
-
end
|
36
|
-
|
37
|
-
def add_id
|
38
|
-
%(id="_#{UUIDTools::UUID.random_create}")
|
39
|
-
end
|
40
|
-
|
41
|
-
def insert_scope(xml)
|
42
|
-
xml.at("./*/sections") or
|
43
|
-
xml.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
|
44
|
-
"<sections><sentinel/></sections>"
|
45
|
-
xml.at("./*/sections/*") or xml.at("./*/sections") << "<sentinel/>"
|
46
|
-
ins = xml.at("//sections").elements.first
|
47
|
-
xml.at("//sections/clause[@type = 'scope']") or
|
48
|
-
ins.previous =
|
49
|
-
"<clause type='scope' #{add_id}><title>#{@i18n.scope}</title><p>" \
|
50
|
-
"#{@i18n.clause_empty}</p></clause>"
|
51
|
-
xml.at("//sentinel")&.remove
|
52
|
-
end
|
53
|
-
|
54
|
-
def insert_norm_ref(xml)
|
55
|
-
xml.at("//bibliography") or
|
56
|
-
xml.at("./*/annex[last()] | ./*/sections").next =
|
57
|
-
"<bibliography><sentinel/></bibliography>"
|
58
|
-
ins = xml.at("//bibliography").elements.first
|
59
|
-
xml.at("//bibliography/references[@normative = 'true']") or
|
60
|
-
ins.previous = "<references #{add_id} normative='true'>" \
|
61
|
-
"<title>#{@i18n.normref}</title></references>"
|
62
|
-
xml.at("//sentinel")&.remove
|
63
|
-
end
|
64
|
-
|
65
|
-
def insert_terms(xml)
|
66
|
-
ins = xml.at("//sections/clause[@type = 'scope']")
|
67
|
-
xml.at("//sections//terms") or
|
68
|
-
ins.next = "<terms #{add_id}><title>#{@i18n.termsdef}</title></terms>"
|
69
|
-
end
|
70
|
-
|
71
|
-
def insert_symbols(xml)
|
72
|
-
ins = xml.at("//sections/terms") ||
|
73
|
-
xml.at("//sections/clause[descendant::terms]")
|
74
|
-
unless xml.at("//sections//definitions")
|
75
|
-
ins.next = "<definitions #{add_id}>" \
|
76
|
-
"<title>#{@i18n.symbolsabbrev}</title></definitions>"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def insert_conventions(xml)
|
81
|
-
ins = xml.at("//sections//definitions") ||
|
82
|
-
xml.at("//sections/clause[descendant::definitions]")
|
83
|
-
unless xml.at("//sections/clause[@type = 'conventions']")
|
84
|
-
ins.next = "<clause #{add_id} type='conventions'>" \
|
85
|
-
"<title>#{@i18n.conventions}</title><p>" \
|
86
|
-
"#{@i18n.clause_empty}</p></clause>"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def insert_empty_clauses(xml)
|
91
|
-
xml.xpath("//terms[not(./term)][not(.//terms)]").each do |c|
|
92
|
-
insert_empty_clauses1(c, @i18n.clause_empty)
|
93
|
-
end
|
94
|
-
xml.xpath("//definitions[not(./dl)]").each do |c|
|
95
|
-
insert_empty_clauses1(c, @i18n.clause_empty)
|
14
|
+
def header_rows_cleanup(xmldoc)
|
15
|
+
super
|
16
|
+
xmldoc.xpath("//table/thead/tr/th").each do |x|
|
17
|
+
x["align"] = "center"
|
96
18
|
end
|
97
19
|
end
|
98
20
|
|
99
|
-
def insert_empty_clauses1(clause, text)
|
100
|
-
clause.at("./p") and return
|
101
|
-
ins = clause.at("./title") or return
|
102
|
-
ins.next = "<p>#{text}</p>"
|
103
|
-
end
|
104
|
-
|
105
21
|
def cleanup(xmldoc)
|
106
22
|
symbols_cleanup(xmldoc)
|
107
23
|
super
|
@@ -110,11 +26,9 @@ module Metanorma
|
|
110
26
|
end
|
111
27
|
|
112
28
|
def smartquotes_cleanup(xmldoc)
|
113
|
-
return super
|
114
|
-
|
29
|
+
@smartquotes and return super
|
115
30
|
xmldoc.traverse do |n|
|
116
|
-
|
117
|
-
|
31
|
+
n.text? or next
|
118
32
|
n.replace(HTMLEntities.new.encode(
|
119
33
|
n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'")
|
120
34
|
.gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic
|
@@ -123,51 +37,6 @@ module Metanorma
|
|
123
37
|
xmldoc
|
124
38
|
end
|
125
39
|
|
126
|
-
def termdef_boilerplate_cleanup(xmldoc); end
|
127
|
-
|
128
|
-
def terms_extract(div)
|
129
|
-
internal = div.at("./terms[@type = 'internal']/title")
|
130
|
-
external = div.at("./terms[@type = 'external']/title")
|
131
|
-
[internal, external]
|
132
|
-
end
|
133
|
-
|
134
|
-
def term_defs_boilerplate(div, _source, _term, _preface, _isodoc)
|
135
|
-
internal, external = terms_extract(div.parent)
|
136
|
-
internal&.next_element&.name == "term" and
|
137
|
-
internal.next = "<p>#{@i18n.internal_terms_boilerplate}</p>"
|
138
|
-
internal and internal&.next_element == nil and
|
139
|
-
internal.next = "<p>#{@i18n.no_terms_boilerplate}</p>"
|
140
|
-
external&.next_element&.name == "term" and
|
141
|
-
external.next = "<p>#{@i18n.external_terms_boilerplate}</p>"
|
142
|
-
external and external&.next_element == nil and
|
143
|
-
external.next = "<p>#{@i18n.no_terms_boilerplate}</p>"
|
144
|
-
!internal and !external and
|
145
|
-
%w(term terms).include? div&.next_element&.name and
|
146
|
-
div.next = "<p>#{@i18n.term_def_boilerplate}</p>"
|
147
|
-
end
|
148
|
-
|
149
|
-
def section_names_terms_cleanup(xml)
|
150
|
-
super
|
151
|
-
replace_title(
|
152
|
-
xml, "//terms[@type = 'internal'] | " \
|
153
|
-
"//clause[./terms[@type = 'internal']]" \
|
154
|
-
"[not(./terms[@type = 'external'])]",
|
155
|
-
@i18n&.internal_termsdef
|
156
|
-
)
|
157
|
-
replace_title(
|
158
|
-
xml, "//terms[@type = 'external'] | " \
|
159
|
-
"//clause[./terms[@type = 'external']]" \
|
160
|
-
"[not(./terms[@type = 'internal'])]",
|
161
|
-
@i18n&.external_termsdef
|
162
|
-
)
|
163
|
-
end
|
164
|
-
|
165
|
-
def symbols_cleanup(xmldoc)
|
166
|
-
sym = xmldoc.at("//definitions/title")
|
167
|
-
sym and sym&.next_element&.name == "dl" and
|
168
|
-
sym.next = "<p>#{@i18n.symbols_boilerplate}</p>"
|
169
|
-
end
|
170
|
-
|
171
40
|
PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
|
172
41
|
|
173
42
|
def pub_class(bib)
|
@@ -214,11 +83,20 @@ module Metanorma
|
|
214
83
|
end
|
215
84
|
end
|
216
85
|
|
217
|
-
def
|
86
|
+
def bibdata_cleanup(xmldoc)
|
218
87
|
super
|
219
|
-
|
220
|
-
|
221
|
-
|
88
|
+
coverpage_images(xmldoc)
|
89
|
+
end
|
90
|
+
|
91
|
+
def coverpage_images(xmldoc)
|
92
|
+
%w(coverpage-image).each do |n|
|
93
|
+
xmldoc.xpath("//bibdata/ext/#{n}").each do |x|
|
94
|
+
ins = add_misc_container(xmldoc)
|
95
|
+
ins << "<presentation-metadata><name>#{n}</name>" \
|
96
|
+
"<value>#{x.remove.children.to_xml}</value>" \
|
97
|
+
"</presentation-metadata>"
|
98
|
+
end
|
99
|
+
end
|
222
100
|
end
|
223
101
|
end
|
224
102
|
end
|