metanorma-itu 1.0.18 → 1.1.0
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 +72 -72
- data/lib/asciidoctor/itu/converter.rb +12 -17
- data/lib/isodoc/itu.rb +1 -0
- data/lib/isodoc/itu/base_convert.rb +8 -3
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +625 -170
- data/lib/isodoc/itu/itu.recommendation.xsl +625 -170
- data/lib/isodoc/itu/itu.resolution.xsl +625 -170
- data/lib/isodoc/itu/pdf_convert.rb +0 -13
- data/lib/isodoc/itu/presentation_xml_convert.rb +10 -0
- data/lib/isodoc/itu/ref.rb +0 -5
- data/lib/isodoc/itu/terms.rb +8 -21
- data/lib/isodoc/itu/word_convert.rb +1 -1
- data/lib/isodoc/itu/xref.rb +40 -16
- data/lib/metanorma/itu/processor.rb +6 -4
- data/lib/metanorma/itu/version.rb +1 -1
- data/metanorma-itu.gemspec +1 -1
- metadata +9 -9
@@ -21,19 +21,6 @@ module IsoDoc
|
|
21
21
|
"itu.recommendation.xsl"
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
def convert(filename, file = nil, debug = false)
|
26
|
-
file = File.read(filename, encoding: "utf-8") if file.nil?
|
27
|
-
docxml, outname_html, dir = convert_init(file, filename, debug)
|
28
|
-
/\.xml$/.match(filename) or
|
29
|
-
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
30
|
-
f.write file
|
31
|
-
f.path
|
32
|
-
end
|
33
|
-
FileUtils.rm_rf dir
|
34
|
-
::Metanorma::Output::XslfoPdf.new.convert(
|
35
|
-
filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
|
36
|
-
end
|
37
24
|
end
|
38
25
|
end
|
39
26
|
end
|
data/lib/isodoc/itu/ref.rb
CHANGED
data/lib/isodoc/itu/terms.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module ITU
|
3
3
|
module BaseConvert
|
4
|
-
|
5
|
-
|
4
|
+
def term_def_title(node)
|
5
|
+
node
|
6
6
|
end
|
7
7
|
|
8
8
|
def terms_defs(node, out, num)
|
@@ -35,7 +35,7 @@ module IsoDoc
|
|
35
35
|
def termdef_parse1(node, div, term, defn, source)
|
36
36
|
div.p **{ class: "TermNum", id: node["id"] } do |p|
|
37
37
|
p.b do |b|
|
38
|
-
b << anchor(node["id"], :label)
|
38
|
+
b << @xrefs.anchor(node["id"], :label)
|
39
39
|
insert_tab(b, 1)
|
40
40
|
term.children.each { |n| parse(n, b) }
|
41
41
|
end
|
@@ -60,24 +60,11 @@ module IsoDoc
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def termnote_parse(node, out)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def termnote_anchor_names(docxml)
|
73
|
-
docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
|
74
|
-
c = IsoDoc::Function::XrefGen::Counter.new
|
75
|
-
notes = t.xpath(ns(".//termnote"))
|
76
|
-
notes.each do |n|
|
77
|
-
return if n["id"].nil? || n["id"].empty?
|
78
|
-
idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
|
79
|
-
@anchors[n["id"]] = anchor_struct(idx, n, @note_xref_lbl,
|
80
|
-
"termnote", false)
|
63
|
+
out.div **note_attrs(node) do |div|
|
64
|
+
first = node.first_element_child
|
65
|
+
div.p do |p|
|
66
|
+
p << note_label(node) # "#{@xrefs.anchor(node['id'], :label) || '???'}: "
|
67
|
+
para_then_remainder(first, node, p, div)
|
81
68
|
end
|
82
69
|
end
|
83
70
|
end
|
@@ -122,7 +122,7 @@ module IsoDoc
|
|
122
122
|
div.p **attr_code(class: "formula") do |p|
|
123
123
|
insert_tab(div, 1)
|
124
124
|
parse(node.at(ns("./stem")), div)
|
125
|
-
lbl = anchor(node['id'], :label, false)
|
125
|
+
lbl = @xrefs.anchor(node['id'], :label, false)
|
126
126
|
unless lbl.nil?
|
127
127
|
insert_tab(div, 1)
|
128
128
|
div << "(#{lbl})"
|
data/lib/isodoc/itu/xref.rb
CHANGED
@@ -4,14 +4,19 @@ require "fileutils"
|
|
4
4
|
|
5
5
|
module IsoDoc
|
6
6
|
module ITU
|
7
|
-
|
7
|
+
class Xref < IsoDoc::Xref
|
8
|
+
def initialize(lang, script, klass, labels, options)
|
9
|
+
super
|
10
|
+
@hierarchical_assets = options[:hierarchical_assets]
|
11
|
+
end
|
12
|
+
|
8
13
|
def annex_name_lbl(clause, num)
|
9
|
-
lbl = clause["obligation"] == "informative" ? @
|
14
|
+
lbl = clause["obligation"] == "informative" ? @labels["appendix"] : @labels["annex"]
|
10
15
|
l10n("<b>#{lbl} #{num}</b>")
|
11
16
|
end
|
12
17
|
|
13
18
|
def annex_names(clause, num)
|
14
|
-
lbl = clause["obligation"] == "informative" ? @
|
19
|
+
lbl = clause["obligation"] == "informative" ? @labels["appendix"] : @labels["annex"]
|
15
20
|
@anchors[clause["id"]] =
|
16
21
|
{ label: annex_name_lbl(clause, num), type: "clause",
|
17
22
|
xref: "#{lbl} #{num}", level: 1 }
|
@@ -81,7 +86,7 @@ module IsoDoc
|
|
81
86
|
end
|
82
87
|
|
83
88
|
def sequential_figure_names(clause)
|
84
|
-
c = IsoDoc::
|
89
|
+
c = IsoDoc::XrefGen::Counter.new
|
85
90
|
j = 0
|
86
91
|
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
|
87
92
|
if t.parent.name == "figure" then j += 1
|
@@ -92,12 +97,12 @@ module IsoDoc
|
|
92
97
|
label = c.print + (j.zero? ? "" : "-#{(96 + j).chr.to_s}")
|
93
98
|
next if t["id"].nil? || t["id"].empty?
|
94
99
|
@anchors[t["id"]] =
|
95
|
-
anchor_struct(label, nil, @
|
100
|
+
anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"])
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
99
104
|
def hierarchical_figure_names(clause, num)
|
100
|
-
c = IsoDoc::
|
105
|
+
c = IsoDoc::XrefGen::Counter.new
|
101
106
|
j = 0
|
102
107
|
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
|
103
108
|
if t.parent.name == "figure" then j += 1
|
@@ -108,7 +113,7 @@ module IsoDoc
|
|
108
113
|
label = "#{num}#{hiersep}#{c.print}" +
|
109
114
|
(j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr.to_s}")
|
110
115
|
next if t["id"].nil? || t["id"].empty?
|
111
|
-
@anchors[t["id"]] = anchor_struct(label, nil, @
|
116
|
+
@anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"], "figure",
|
112
117
|
t["unnumbered"])
|
113
118
|
end
|
114
119
|
end
|
@@ -116,7 +121,8 @@ module IsoDoc
|
|
116
121
|
def sequential_formula_names(clause)
|
117
122
|
clause&.first&.xpath(ns(MIDDLE_SECTIONS))&.each do |c|
|
118
123
|
if c["id"] && @anchors[c["id"]]
|
119
|
-
hierarchical_formula_names(c, @anchors[c["id"]][:label] ||
|
124
|
+
hierarchical_formula_names(c, @anchors[c["id"]][:label] ||
|
125
|
+
@anchors[c["id"]][:xref] || "???")
|
120
126
|
else
|
121
127
|
hierarchical_formula_names(c, "???")
|
122
128
|
end
|
@@ -124,15 +130,33 @@ module IsoDoc
|
|
124
130
|
end
|
125
131
|
|
126
132
|
def hierarchical_formula_names(clause, num)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
133
|
+
c = IsoDoc::XrefGen::Counter.new
|
134
|
+
clause.xpath(ns(".//formula")).each do |t|
|
135
|
+
next if t["id"].nil? || t["id"].empty?
|
136
|
+
@anchors[t["id"]] =
|
137
|
+
anchor_struct("#{num}-#{c.increment(t).print}", nil,
|
138
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
139
|
+
"formula", t["unnumbered"])
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def reference_names(ref)
|
144
|
+
super
|
145
|
+
@anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].sub(/^\[/, '').sub(/\]$/, '') }
|
146
|
+
end
|
147
|
+
|
148
|
+
def termnote_anchor_names(docxml)
|
149
|
+
docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
|
150
|
+
c = IsoDoc::XrefGen::Counter.new
|
151
|
+
notes = t.xpath(ns(".//termnote"))
|
152
|
+
notes.each do |n|
|
153
|
+
return if n["id"].nil? || n["id"].empty?
|
154
|
+
idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
|
155
|
+
@anchors[n["id"]] = anchor_struct(idx, n, @labels["note_xref"],
|
156
|
+
"termnote", false)
|
157
|
+
end
|
158
|
+
end
|
134
159
|
end
|
135
|
-
end
|
136
160
|
end
|
137
161
|
end
|
138
162
|
end
|
@@ -34,14 +34,16 @@ module Metanorma
|
|
34
34
|
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
35
35
|
end
|
36
36
|
|
37
|
-
def output(isodoc_node, outname, format, options={})
|
37
|
+
def output(isodoc_node, inname, outname, format, options={})
|
38
38
|
case format
|
39
39
|
when :html
|
40
|
-
IsoDoc::ITU::HtmlConvert.new(options).convert(
|
40
|
+
IsoDoc::ITU::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
41
41
|
when :doc
|
42
|
-
IsoDoc::ITU::WordConvert.new(options).convert(
|
42
|
+
IsoDoc::ITU::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
43
43
|
when :pdf
|
44
|
-
IsoDoc::ITU::PdfConvert.new(options).convert(
|
44
|
+
IsoDoc::ITU::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
45
|
+
when :presentation
|
46
|
+
IsoDoc::ITU::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
45
47
|
else
|
46
48
|
super
|
47
49
|
end
|
data/metanorma-itu.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
28
28
|
spec.add_dependency "ruby-jing"
|
29
29
|
spec.add_dependency "metanorma-standoc", "~> 1.4.0"
|
30
|
-
spec.add_dependency "isodoc", "~> 1.
|
30
|
+
spec.add_dependency "isodoc", "~> 1.1.0"
|
31
31
|
|
32
32
|
spec.add_development_dependency "byebug", "~> 9.1"
|
33
33
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: byebug
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- lib/isodoc/itu/itu.resolution.xsl
|
280
280
|
- lib/isodoc/itu/metadata.rb
|
281
281
|
- lib/isodoc/itu/pdf_convert.rb
|
282
|
+
- lib/isodoc/itu/presentation_xml_convert.rb
|
282
283
|
- lib/isodoc/itu/ref.rb
|
283
284
|
- lib/isodoc/itu/terms.rb
|
284
285
|
- lib/isodoc/itu/word_convert.rb
|
@@ -292,7 +293,7 @@ homepage: https://github.com/metanorma/metanorma-itu
|
|
292
293
|
licenses:
|
293
294
|
- BSD-2-Clause
|
294
295
|
metadata: {}
|
295
|
-
post_install_message:
|
296
|
+
post_install_message:
|
296
297
|
rdoc_options: []
|
297
298
|
require_paths:
|
298
299
|
- lib
|
@@ -307,9 +308,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
308
|
- !ruby/object:Gem::Version
|
308
309
|
version: '0'
|
309
310
|
requirements: []
|
310
|
-
|
311
|
-
|
312
|
-
signing_key:
|
311
|
+
rubygems_version: 3.0.3
|
312
|
+
signing_key:
|
313
313
|
specification_version: 4
|
314
314
|
summary: Metanorma for the ITU
|
315
315
|
test_files: []
|