metanorma-itu 1.0.14 → 1.0.15
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 +9 -2
- data/lib/asciidoctor/itu/converter.rb +0 -11
- data/lib/asciidoctor/itu/isodoc.rng +6 -3
- data/lib/isodoc/itu/html_convert.rb +3 -3
- data/lib/isodoc/itu/itu.recommendation-annex.xsl +3589 -0
- data/lib/isodoc/itu/itu.recommendation.xsl +243 -105
- data/lib/isodoc/itu/itu.resolution.xsl +243 -105
- data/lib/isodoc/itu/pdf_convert.rb +10 -3
- data/lib/isodoc/itu/ref.rb +1 -1
- data/lib/isodoc/itu/xref.rb +14 -10
- data/lib/metanorma/itu/processor.rb +2 -2
- data/lib/metanorma/itu/version.rb +1 -1
- metadata +3 -2
@@ -13,10 +13,18 @@ module IsoDoc
|
|
13
13
|
super
|
14
14
|
end
|
15
15
|
|
16
|
+
def pdf_stylesheet(docxml)
|
17
|
+
case doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
|
18
|
+
when "resolution" then "itu.resolution.xsl"
|
19
|
+
when "recommendation-annex" then "itu.recommendation-annex.xsl"
|
20
|
+
else
|
21
|
+
"itu.recommendation.xsl"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
def convert(filename, file = nil, debug = false)
|
17
26
|
file = File.read(filename, encoding: "utf-8") if file.nil?
|
18
27
|
docxml, outname_html, dir = convert_init(file, filename, debug)
|
19
|
-
resolution = docxml.at(ns("//bibdata/ext[doctype = 'resolution']"))
|
20
28
|
/\.xml$/.match(filename) or
|
21
29
|
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
22
30
|
f.write file
|
@@ -24,8 +32,7 @@ module IsoDoc
|
|
24
32
|
end
|
25
33
|
FileUtils.rm_rf dir
|
26
34
|
::Metanorma::Output::XslfoPdf.new.convert(
|
27
|
-
filename, outname_html + ".pdf",
|
28
|
-
File.join(@libdir, resolution ? "itu.resolution.xsl" : "itu.recommendation.xsl"))
|
35
|
+
filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
|
29
36
|
end
|
30
37
|
end
|
31
38
|
end
|
data/lib/isodoc/itu/ref.rb
CHANGED
@@ -6,7 +6,7 @@ module IsoDoc
|
|
6
6
|
module ITU
|
7
7
|
module BaseConvert
|
8
8
|
def norm_ref(isoxml, out, num)
|
9
|
-
q = "//bibliography/references[
|
9
|
+
q = "//bibliography/references[@normative = 'true']"
|
10
10
|
f = isoxml.at(ns(q)) or return num
|
11
11
|
out.div do |div|
|
12
12
|
num = num + 1
|
data/lib/isodoc/itu/xref.rb
CHANGED
@@ -15,9 +15,13 @@ module IsoDoc
|
|
15
15
|
@anchors[clause["id"]] =
|
16
16
|
{ label: annex_name_lbl(clause, num), type: "clause",
|
17
17
|
xref: "#{lbl} #{num}", level: 1 }
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
if a = single_annex_special_section(clause)
|
19
|
+
annex_names1(a, "#{num}", 1)
|
20
|
+
else
|
21
|
+
clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).
|
22
|
+
each_with_index do |c, i|
|
23
|
+
annex_names1(c, "#{num}.#{i + 1}", 2)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
hierarchical_asset_names(clause, num)
|
23
27
|
end
|
@@ -52,8 +56,8 @@ module IsoDoc
|
|
52
56
|
hierarchical_asset_names(d.xpath("//xmlns:preface/child::*"), "Preface") :
|
53
57
|
sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
|
54
58
|
n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
|
55
|
-
n = section_names(d.at(ns("//bibliography/clause[
|
56
|
-
"//bibliography/references[
|
59
|
+
n = section_names(d.at(ns("//bibliography/clause[.//references[@normative = 'true']] | "\
|
60
|
+
"//bibliography/references[@normative = 'true']")), n, 1)
|
57
61
|
n = section_names(d.at(ns("//sections/terms | "\
|
58
62
|
"//sections/clause[descendant::terms]")), n, 1)
|
59
63
|
n = section_names(d.at(ns("//sections/definitions")), n, 1)
|
@@ -68,10 +72,10 @@ module IsoDoc
|
|
68
72
|
end
|
69
73
|
|
70
74
|
MIDDLE_SECTIONS = "//clause[title = 'Scope'] | "\
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
"//foreword | //introduction | //acknowledgements | "\
|
76
|
+
"//references[@normative = 'true'] | "\
|
77
|
+
"//sections/terms | //preface/clause | "\
|
78
|
+
"//sections/definitions | //clause[parent::sections]".freeze
|
75
79
|
|
76
80
|
def middle_section_asset_names(d)
|
77
81
|
return super unless @hierarchical_assets
|
@@ -116,7 +120,7 @@ module IsoDoc
|
|
116
120
|
def sequential_formula_names(clause)
|
117
121
|
clause&.first&.xpath(ns(MIDDLE_SECTIONS))&.each do |c|
|
118
122
|
if c["id"] && @anchors[c["id"]]
|
119
|
-
|
123
|
+
hierarchical_formula_names(c, @anchors[c["id"]][:label] || @anchors[c["id"]][:xref] || "???")
|
120
124
|
else
|
121
125
|
hierarchical_formula_names(c, "???")
|
122
126
|
end
|
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.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- lib/isodoc/itu/html/wordstyle.scss
|
276
276
|
- lib/isodoc/itu/html_convert.rb
|
277
277
|
- lib/isodoc/itu/i18n-en.yaml
|
278
|
+
- lib/isodoc/itu/itu.recommendation-annex.xsl
|
278
279
|
- lib/isodoc/itu/itu.recommendation.xsl
|
279
280
|
- lib/isodoc/itu/itu.resolution.xsl
|
280
281
|
- lib/isodoc/itu/metadata.rb
|