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
@@ -0,0 +1,150 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module ITU
|
3
|
+
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
|
+
def insert_missing_sections(xml)
|
20
|
+
xml.at("//metanorma-extension/semantic-metadata/" \
|
21
|
+
"headless[text() = 'true']") and return nil
|
22
|
+
insert_scope(xml)
|
23
|
+
insert_norm_ref(xml)
|
24
|
+
insert_terms(xml)
|
25
|
+
insert_symbols(xml)
|
26
|
+
insert_conventions(xml)
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_id
|
30
|
+
%(id="_#{UUIDTools::UUID.random_create}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def insert_scope(xml)
|
34
|
+
xml.at("./*/sections") or
|
35
|
+
xml.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
|
36
|
+
"<sections><sentinel/></sections>"
|
37
|
+
xml.at("./*/sections/*") or xml.at("./*/sections") << "<sentinel/>"
|
38
|
+
ins = xml.at("//sections").elements.first
|
39
|
+
xml.at("//sections/clause[@type = 'scope']") or
|
40
|
+
ins.previous =
|
41
|
+
"<clause type='scope' #{add_id}><title>#{@i18n.scope}</title><p>" \
|
42
|
+
"#{@i18n.clause_empty}</p></clause>"
|
43
|
+
xml.at("//sentinel")&.remove
|
44
|
+
end
|
45
|
+
|
46
|
+
def insert_norm_ref(xml)
|
47
|
+
xml.at("//bibliography") or
|
48
|
+
xml.at("./*/annex[last()] | ./*/sections").next =
|
49
|
+
"<bibliography><sentinel/></bibliography>"
|
50
|
+
ins = xml.at("//bibliography").elements.first
|
51
|
+
xml.at("//bibliography/references[@normative = 'true']") or
|
52
|
+
ins.previous = "<references #{add_id} normative='true'>" \
|
53
|
+
"<title>#{@i18n.normref}</title></references>"
|
54
|
+
xml.at("//sentinel")&.remove
|
55
|
+
end
|
56
|
+
|
57
|
+
def insert_terms(xml)
|
58
|
+
ins = xml.at("//sections/clause[@type = 'scope']")
|
59
|
+
xml.at("//sections//terms") or
|
60
|
+
ins.next = "<terms #{add_id}><title>#{@i18n.termsdef}</title></terms>"
|
61
|
+
end
|
62
|
+
|
63
|
+
def insert_symbols(xml)
|
64
|
+
ins = xml.at("//sections/terms") ||
|
65
|
+
xml.at("//sections/clause[descendant::terms]")
|
66
|
+
unless xml.at("//sections//definitions")
|
67
|
+
ins.next = "<definitions #{add_id}>" \
|
68
|
+
"<title>#{@i18n.symbolsabbrev}</title></definitions>"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def insert_conventions(xml)
|
73
|
+
ins = xml.at("//sections//definitions") ||
|
74
|
+
xml.at("//sections/clause[descendant::definitions]")
|
75
|
+
unless xml.at("//sections/clause[@type = 'conventions']")
|
76
|
+
ins.next = "<clause #{add_id} type='conventions'>" \
|
77
|
+
"<title>#{@i18n.conventions}</title><p>" \
|
78
|
+
"#{@i18n.clause_empty}</p></clause>"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def insert_empty_clauses(xml)
|
83
|
+
xml.xpath("//terms[not(./term)][not(.//terms)]").each do |c|
|
84
|
+
insert_empty_clauses1(c, @i18n.clause_empty)
|
85
|
+
end
|
86
|
+
xml.xpath("//definitions[not(./dl)]").each do |c|
|
87
|
+
insert_empty_clauses1(c, @i18n.clause_empty)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def insert_empty_clauses1(clause, text)
|
92
|
+
clause.at("./p") and return
|
93
|
+
ins = clause.at("./title") or return
|
94
|
+
ins.next = "<p>#{text}</p>"
|
95
|
+
end
|
96
|
+
|
97
|
+
def termdef_boilerplate_cleanup(xmldoc); end
|
98
|
+
|
99
|
+
def terms_extract(div)
|
100
|
+
internal = div.at("./terms[@type = 'internal']/title")
|
101
|
+
external = div.at("./terms[@type = 'external']/title")
|
102
|
+
[internal, external]
|
103
|
+
end
|
104
|
+
|
105
|
+
def term_defs_boilerplate(div, _source, _term, _preface, _isodoc)
|
106
|
+
internal, external = terms_extract(div.parent)
|
107
|
+
internal&.next_element&.name == "term" and
|
108
|
+
internal.next = "<p>#{@i18n.internal_terms_boilerplate}</p>"
|
109
|
+
internal and internal&.next_element == nil and
|
110
|
+
internal.next = "<p>#{@i18n.no_terms_boilerplate}</p>"
|
111
|
+
external&.next_element&.name == "term" and
|
112
|
+
external.next = "<p>#{@i18n.external_terms_boilerplate}</p>"
|
113
|
+
external and external&.next_element == nil and
|
114
|
+
external.next = "<p>#{@i18n.no_terms_boilerplate}</p>"
|
115
|
+
!internal and !external and
|
116
|
+
%w(term terms).include? div&.next_element&.name and
|
117
|
+
div.next = "<p>#{@i18n.term_def_boilerplate}</p>"
|
118
|
+
end
|
119
|
+
|
120
|
+
def section_names_terms_cleanup(xml)
|
121
|
+
super
|
122
|
+
replace_title(
|
123
|
+
xml, "//terms[@type = 'internal'] | " \
|
124
|
+
"//clause[./terms[@type = 'internal']]" \
|
125
|
+
"[not(./terms[@type = 'external'])]",
|
126
|
+
@i18n&.internal_termsdef
|
127
|
+
)
|
128
|
+
replace_title(
|
129
|
+
xml, "//terms[@type = 'external'] | " \
|
130
|
+
"//clause[./terms[@type = 'external']]" \
|
131
|
+
"[not(./terms[@type = 'internal'])]",
|
132
|
+
@i18n&.external_termsdef
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
def symbols_cleanup(xmldoc)
|
137
|
+
sym = xmldoc.at("//definitions/title")
|
138
|
+
sym and sym&.next_element&.name == "dl" and
|
139
|
+
sym.next = "<p>#{@i18n.symbols_boilerplate}</p>"
|
140
|
+
end
|
141
|
+
|
142
|
+
def sections_names_cleanup(xml)
|
143
|
+
super
|
144
|
+
t = xml.at("//preface//abstract") or return
|
145
|
+
t["id"] == "_summary" and
|
146
|
+
replace_title(xml, "//preface//abstract", @i18n&.summary)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -36,7 +36,8 @@ module Metanorma
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def doctype(node)
|
39
|
-
ret = node.attr("doctype")&.gsub(/\s+/, "-")&.downcase ||
|
39
|
+
ret = node.attr("doctype")&.gsub(/\s+/, "-")&.downcase ||
|
40
|
+
"recommendation"
|
40
41
|
ret = "recommendation" if ret == "article"
|
41
42
|
ret
|
42
43
|
end
|
@@ -87,7 +88,7 @@ module Metanorma
|
|
87
88
|
|
88
89
|
def sectiontype(node, level = true)
|
89
90
|
ret = super
|
90
|
-
hdr = sectiontype_streamline(node
|
91
|
+
hdr = sectiontype_streamline(node.attr("heading")&.downcase)
|
91
92
|
return nil if ret == "terms and definitions" &&
|
92
93
|
hdr != "terms and definitions" && node.level > 1
|
93
94
|
return nil if ret == "symbols and abbreviated terms" &&
|
@@ -120,14 +121,16 @@ module Metanorma
|
|
120
121
|
node.option?("unnumbered") and attrs[:unnumbered] = true
|
121
122
|
case sectiontype1(node)
|
122
123
|
when "conventions" then attrs = attrs.merge(type: "conventions")
|
123
|
-
when "history"
|
124
|
-
attrs[:preface] and attrs = attrs.merge(type:
|
125
|
-
when "source"
|
126
|
-
attrs[:preface] and attrs = attrs.merge(type: "source")
|
124
|
+
when "history", "source"
|
125
|
+
attrs[:preface] and attrs = attrs.merge(type: sectiontype1(node))
|
127
126
|
end
|
128
127
|
super
|
129
128
|
end
|
130
129
|
|
130
|
+
def document_scheme(node)
|
131
|
+
super || "current"
|
132
|
+
end
|
133
|
+
|
131
134
|
def html_extract_attributes(node)
|
132
135
|
super.merge(hierarchicalassets:
|
133
136
|
node.attr("hierarchical-object-numbering"))
|
@@ -141,7 +144,8 @@ module Metanorma
|
|
141
144
|
def presentation_xml_converter(node)
|
142
145
|
IsoDoc::ITU::PresentationXMLConvert
|
143
146
|
.new(html_extract_attributes(node)
|
144
|
-
.merge(output_formats: ::Metanorma::ITU::Processor.new
|
147
|
+
.merge(output_formats: ::Metanorma::ITU::Processor.new
|
148
|
+
.output_formats))
|
145
149
|
end
|
146
150
|
|
147
151
|
def html_converter(node)
|
data/lib/metanorma/itu/front.rb
CHANGED
@@ -7,7 +7,7 @@ module Metanorma
|
|
7
7
|
module ITU
|
8
8
|
class Converter < Standoc::Converter
|
9
9
|
def metadata_status(node, xml)
|
10
|
-
stage =
|
10
|
+
stage = node.attr("status") || node.attr("docstage") || "published"
|
11
11
|
stage = "draft" if node.attributes.has_key?("draft")
|
12
12
|
xml.status do |s|
|
13
13
|
s.stage stage
|
@@ -36,9 +36,8 @@ module Metanorma
|
|
36
36
|
|
37
37
|
def title_otherlangs(node, xml)
|
38
38
|
node.attributes.each do |k, v|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
/^(?:annex)?title-(?<lang>.+)$/ =~ k or next
|
40
|
+
lang == @lang and next
|
42
41
|
type = /^annex/.match?(k) ? "annex" : "main"
|
43
42
|
xml.title **attr_code(title_attr(type, lang)) do |t|
|
44
43
|
t << Metanorma::Utils::asciidoc_sub(v)
|
@@ -49,7 +48,8 @@ module Metanorma
|
|
49
48
|
def title(node, xml)
|
50
49
|
title_defaultlang(node, xml)
|
51
50
|
title_otherlangs(node, xml)
|
52
|
-
%w(subtitle amendment-title corrigendum-title
|
51
|
+
%w(subtitle amendment-title corrigendum-title collection-title
|
52
|
+
slogan-title).each do |t|
|
53
53
|
other_title_defaultlang(node, xml, t)
|
54
54
|
other_title_otherlangs(node, xml, t)
|
55
55
|
end
|
@@ -64,9 +64,8 @@ module Metanorma
|
|
64
64
|
|
65
65
|
def other_title_otherlangs(node, xml, type)
|
66
66
|
node.attributes.each do |k, v|
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
m = /^#{type}-(?<lang>.+)$/.match(k) or next
|
68
|
+
m[:lang] == @lang and next
|
70
69
|
xml.title **attr_code(title_attr(type.sub(/-title/, ""),
|
71
70
|
m[:lang])) do |t|
|
72
71
|
t << Metanorma::Utils::asciidoc_sub(v)
|
@@ -87,6 +86,7 @@ module Metanorma
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def metadata_committee(node, xml)
|
89
|
+
metadata_sector(node, xml)
|
90
90
|
metadata_committee1(node, xml, "")
|
91
91
|
suffix = 2
|
92
92
|
while node.attr("bureau_#{suffix}")
|
@@ -95,6 +95,13 @@ module Metanorma
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
def metadata_sector(node, xml)
|
99
|
+
s = node.attr("sector") or return
|
100
|
+
xml.editorialgroup do |a|
|
101
|
+
a.sector { |x| x << s }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
98
105
|
def metadata_committee1(node, xml, suffix)
|
99
106
|
xml.editorialgroup do |a|
|
100
107
|
a.bureau ( node.attr("bureau#{suffix}") || "T")
|
@@ -123,23 +130,17 @@ module Metanorma
|
|
123
130
|
end
|
124
131
|
|
125
132
|
def metadata_series(node, xml)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
node.attr("series2") and
|
135
|
-
xml.series **{ type: "tertiary" } do |s|
|
136
|
-
s.title node.attr("series2")
|
137
|
-
end
|
133
|
+
{ series: "main", series1: "secondary", series2: "tertiary" }
|
134
|
+
.each do |k, v|
|
135
|
+
node.attr(k.to_s) and
|
136
|
+
xml.series **{ type: v } do |s|
|
137
|
+
s.title node.attr(k.to_s)
|
138
|
+
end
|
139
|
+
end
|
138
140
|
end
|
139
141
|
|
140
142
|
def metadata_recommendationstatus(node, xml)
|
141
|
-
|
142
|
-
|
143
|
+
node.attr("recommendation-from") or return
|
143
144
|
xml.recommendationstatus do |s|
|
144
145
|
s.from node.attr("recommendation-from")
|
145
146
|
s.to node.attr("recommendation-to") if node.attr("recommendation-to")
|
@@ -190,6 +191,18 @@ module Metanorma
|
|
190
191
|
end
|
191
192
|
end
|
192
193
|
|
194
|
+
def metadata_coverpage_images(node, xml)
|
195
|
+
%w(coverpage-image).each do |n|
|
196
|
+
if a = node.attr(n)
|
197
|
+
xml.send n do |c|
|
198
|
+
a.split(",").each do |x|
|
199
|
+
c.image src: x
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
193
206
|
def metadata_ext(node, xml)
|
194
207
|
metadata_doctype(node, xml)
|
195
208
|
metadata_subdoctype(node, xml)
|
@@ -199,6 +212,7 @@ module Metanorma
|
|
199
212
|
metadata_ip_notice(node, xml)
|
200
213
|
metadata_techreport(node, xml)
|
201
214
|
structured_id(node, xml)
|
215
|
+
metadata_coverpage_images(node, xml)
|
202
216
|
end
|
203
217
|
end
|
204
218
|
end
|
data/metanorma-itu.gemspec
CHANGED
@@ -25,7 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
27
27
|
|
28
|
-
spec.add_dependency "metanorma-standoc", "~> 2.8.
|
28
|
+
spec.add_dependency "metanorma-standoc", "~> 2.8.4"
|
29
|
+
spec.add_dependency "pubid-itu"
|
29
30
|
spec.add_dependency "twitter_cldr", ">= 3.0.0"
|
30
31
|
spec.add_dependency "tzinfo-data" # we need this for windows only
|
31
32
|
|
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: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-standoc
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.8.
|
19
|
+
version: 2.8.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.8.
|
26
|
+
version: 2.8.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pubid-itu
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: twitter_cldr
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,6 +296,7 @@ files:
|
|
282
296
|
- lib/isodoc/itu/pdf_convert.rb
|
283
297
|
- lib/isodoc/itu/presentation_bibdata.rb
|
284
298
|
- lib/isodoc/itu/presentation_preface.rb
|
299
|
+
- lib/isodoc/itu/presentation_ref.rb
|
285
300
|
- lib/isodoc/itu/presentation_xml_convert.rb
|
286
301
|
- lib/isodoc/itu/ref.rb
|
287
302
|
- lib/isodoc/itu/terms.rb
|
@@ -296,6 +311,7 @@ files:
|
|
296
311
|
- lib/metanorma/itu/biblio.rng
|
297
312
|
- lib/metanorma/itu/boilerplate.adoc
|
298
313
|
- lib/metanorma/itu/cleanup.rb
|
314
|
+
- lib/metanorma/itu/cleanup_section.rb
|
299
315
|
- lib/metanorma/itu/converter.rb
|
300
316
|
- lib/metanorma/itu/front.rb
|
301
317
|
- lib/metanorma/itu/front_id.rb
|