metanorma-un 0.3.11 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +0 -1
- data/.github/workflows/ubuntu.yml +10 -7
- data/.github/workflows/windows.yml +0 -1
- data/Rakefile +2 -0
- data/lib/asciidoctor/un/converter.rb +51 -39
- data/lib/asciidoctor/un/isodoc.rng +12 -6
- data/lib/asciidoctor/un/validate.rb +2 -1
- data/lib/isodoc/un.rb +1 -0
- data/lib/isodoc/un/base_convert.rb +5 -52
- data/lib/isodoc/un/html/htmlstyle.css +1096 -0
- data/lib/isodoc/un/html/unece.css +818 -0
- data/lib/isodoc/un/html/wordstyle.css +1237 -0
- data/lib/isodoc/un/html/wordstyle.scss +0 -1
- data/lib/isodoc/un/html_convert.rb +9 -21
- data/lib/isodoc/un/i18n-en.yaml +2 -0
- data/lib/isodoc/un/i18n.rb +11 -0
- data/lib/isodoc/un/init.rb +29 -0
- data/lib/isodoc/un/metadata.rb +23 -12
- data/lib/isodoc/un/pdf_convert.rb +0 -14
- data/lib/isodoc/un/presentation_xml_convert.rb +53 -0
- data/lib/isodoc/un/un.plenary-attachment.xsl +1703 -1919
- data/lib/isodoc/un/un.plenary.xsl +1703 -1919
- data/lib/isodoc/un/un.recommendation.xsl +1794 -11473
- data/lib/isodoc/un/word_convert.rb +17 -23
- data/lib/isodoc/un/xref.rb +14 -17
- data/lib/metanorma/un/processor.rb +6 -8
- data/lib/metanorma/un/version.rb +1 -1
- data/metanorma-unece.gemspec +3 -4
- metadata +31 -39
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "base_convert"
|
2
|
+
require_relative "init"
|
2
3
|
require "isodoc"
|
3
4
|
|
4
5
|
module IsoDoc
|
@@ -15,8 +16,10 @@ module IsoDoc
|
|
15
16
|
|
16
17
|
def default_fonts(options)
|
17
18
|
{
|
18
|
-
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
|
19
|
-
|
19
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
|
20
|
+
'"Times New Roman",serif'),
|
21
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
|
22
|
+
'"Times New Roman",serif'),
|
20
23
|
monospacefont: '"Courier New",monospace'
|
21
24
|
}
|
22
25
|
end
|
@@ -47,7 +50,8 @@ module IsoDoc
|
|
47
50
|
|
48
51
|
def make_body(xml, docxml)
|
49
52
|
plenary = is_plenary?(docxml)
|
50
|
-
if plenary &&
|
53
|
+
if plenary &&
|
54
|
+
@wordcoverpage == html_doc_path("word_unece_titlepage.html")
|
51
55
|
@wordcoverpage = html_doc_path("word_unece_plenary_titlepage.html")
|
52
56
|
end
|
53
57
|
@wordintropage = nil if plenary && !@toc
|
@@ -94,27 +98,12 @@ module IsoDoc
|
|
94
98
|
end_line(isoxml, out)
|
95
99
|
end
|
96
100
|
|
97
|
-
def clause_parse_title(node, div, c1, out)
|
98
|
-
if node["inline-header"] == "true"
|
99
|
-
inline_header_title(out, node, c1)
|
100
|
-
else
|
101
|
-
div.send "h#{anchor(node['id'], :level, false) || '1'}" do |h|
|
102
|
-
lbl = anchor(node['id'], :label, false)
|
103
|
-
if lbl && !@suppressheadingnumbers
|
104
|
-
h << "#{lbl}. "
|
105
|
-
insert_tab(h, 1)
|
106
|
-
end
|
107
|
-
c1&.children&.each { |c2| parse(c2, h) }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
101
|
def introduction(isoxml, out)
|
113
102
|
f = isoxml.at(ns("//introduction")) || return
|
114
103
|
out.div **{ class: "Section3", id: f["id"] } do |div|
|
115
104
|
page_break(out)
|
116
105
|
div.p(**{ class: "IntroTitle" }) do |h1|
|
117
|
-
h1
|
106
|
+
f&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
|
118
107
|
end
|
119
108
|
f.elements.each do |e|
|
120
109
|
parse(e, div) unless e.name == "title"
|
@@ -127,7 +116,7 @@ module IsoDoc
|
|
127
116
|
out.div **attr_code(id: f["id"]) do |s|
|
128
117
|
page_break(out)
|
129
118
|
s.p(**{ class: "ForewordTitle" }) do |h1|
|
130
|
-
h1
|
119
|
+
f&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
|
131
120
|
end
|
132
121
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
133
122
|
end
|
@@ -135,7 +124,8 @@ module IsoDoc
|
|
135
124
|
|
136
125
|
def word_preface(docxml)
|
137
126
|
super
|
138
|
-
preface_container =
|
127
|
+
preface_container =
|
128
|
+
docxml.at("//div[@id = 'preface_container']") # recommendation
|
139
129
|
abstractbox = docxml.at("//div[@id = 'abstractbox']") # plenary
|
140
130
|
foreword = docxml.at("//p[@class = 'ForewordTitle']/..")
|
141
131
|
intro = docxml.at("//p[@class = 'IntroTitle']/..")
|
@@ -163,18 +153,22 @@ module IsoDoc
|
|
163
153
|
f = isoxml.at(ns("//abstract")) || return
|
164
154
|
out.div **attr_code(id: f["id"]) do |s|
|
165
155
|
page_break(out)
|
166
|
-
s.p(**{ class: "AbstractTitle" })
|
156
|
+
s.p(**{ class: "AbstractTitle" }) do |h1|
|
157
|
+
f&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
|
158
|
+
end
|
167
159
|
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
168
160
|
end
|
169
161
|
end
|
170
162
|
|
171
163
|
def authority_cleanup(docxml)
|
172
164
|
super
|
173
|
-
a = docxml.at("//div[@id = 'boilerplate-ECEhdr']") and
|
165
|
+
a = docxml.at("//div[@id = 'boilerplate-ECEhdr']") and
|
166
|
+
a["class"] = "boilerplate-ECEhdr"
|
174
167
|
docxml&.at("//div[@class = 'authority']")&.remove
|
175
168
|
end
|
176
169
|
|
177
170
|
include BaseConvert
|
171
|
+
include Init
|
178
172
|
end
|
179
173
|
end
|
180
174
|
end
|
data/lib/isodoc/un/xref.rb
CHANGED
@@ -2,9 +2,7 @@ require "roman-numerals"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
module UN
|
5
|
-
|
6
|
-
MIDDLE_CLAUSE = "//clause[parent::sections]".freeze
|
7
|
-
|
5
|
+
class Xref < IsoDoc::Xref
|
8
6
|
def initial_anchor_names(d)
|
9
7
|
preface_names(d.at(ns("//preface/abstract")))
|
10
8
|
preface_names(d.at(ns("//foreword")))
|
@@ -75,12 +73,11 @@ module IsoDoc
|
|
75
73
|
num = num + 1
|
76
74
|
lbl = levelnumber(num, 1)
|
77
75
|
@anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
|
78
|
-
xref: l10n("#{@
|
76
|
+
xref: l10n("#{@labels['clause']} #{lbl}") }
|
79
77
|
i = 1
|
80
78
|
clause.xpath(ns(NONTERMINAL)).each do |c|
|
81
|
-
next if c["unnumbered"] == "true"
|
82
79
|
section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
|
83
|
-
i += 1 if !leaf_section?(c)
|
80
|
+
i += 1 if !leaf_section?(c) && c["unnumbered"] != "true"
|
84
81
|
end
|
85
82
|
num
|
86
83
|
end
|
@@ -88,22 +85,22 @@ module IsoDoc
|
|
88
85
|
def section_names1(clause, num, level)
|
89
86
|
leaf_section?(clause) and label_leaf_section(clause, level) and return
|
90
87
|
/\.(?<leafnum>[^.]+$)/ =~ num
|
91
|
-
|
92
|
-
|
88
|
+
clause["unnumbered"] == "true" or
|
89
|
+
@anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
|
90
|
+
xref: l10n("#{@labels['clause']} #{num}") }
|
93
91
|
i = 1
|
94
92
|
clause.xpath(ns(NONTERMINAL)).each do |c|
|
95
|
-
next if c["unnumbered"] == "true"
|
96
93
|
section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
|
97
|
-
i += 1 if !leaf_section?(c)
|
94
|
+
i += 1 if !leaf_section?(c) && c["unnumbered"] != "true"
|
98
95
|
end
|
99
96
|
end
|
100
97
|
|
101
98
|
def annex_name_lbl(clause, num)
|
102
|
-
l10n("<
|
99
|
+
l10n("<strong>#{@labels['annex']} #{num}</strong>")
|
103
100
|
end
|
104
101
|
|
105
102
|
SUBCLAUSES =
|
106
|
-
|
103
|
+
"./clause | ./references | ./term | ./terms | ./definitions".freeze
|
107
104
|
|
108
105
|
|
109
106
|
def annex_names(clause, num)
|
@@ -112,13 +109,13 @@ module IsoDoc
|
|
112
109
|
label_annex_leaf_section(clause, num, 1) and return
|
113
110
|
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
|
114
111
|
type: "clause",
|
115
|
-
xref: "#{@
|
112
|
+
xref: "#{@labels['annex']} #{num}", level: 1 }
|
116
113
|
if a = single_annex_special_section(clause)
|
117
114
|
annex_names1(a, "#{num}", 1)
|
118
115
|
else
|
119
116
|
i = 1
|
120
117
|
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
121
|
-
|
118
|
+
next if c["unnumbered"] == "true"
|
122
119
|
annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
|
123
120
|
i += 1 if !leaf_section?(c)
|
124
121
|
end
|
@@ -129,7 +126,7 @@ module IsoDoc
|
|
129
126
|
leaf_section?(clause) and
|
130
127
|
label_annex_leaf_section(clause, num, level) and return
|
131
128
|
/\.(?<leafnum>[^.]+$)/ =~ num
|
132
|
-
@anchors[clause["id"]] = { label: leafnum, xref: "#{@
|
129
|
+
@anchors[clause["id"]] = { label: leafnum, xref: "#{@labels['annex']} #{num}",
|
133
130
|
level: level, type: "clause" }
|
134
131
|
i = 1
|
135
132
|
clause.xpath(ns("./clause | ./references")).each do |c|
|
@@ -158,7 +155,7 @@ module IsoDoc
|
|
158
155
|
clause.xpath(ns(".//admonition")).each do |t|
|
159
156
|
next if t["id"].nil? || t["id"].empty?
|
160
157
|
i += 1 unless t["unnumbered"] == "true"
|
161
|
-
@anchors[t["id"]] = anchor_struct(i.to_s, nil, @
|
158
|
+
@anchors[t["id"]] = anchor_struct(i.to_s, nil, @labels["admonition"],
|
162
159
|
"box", t["unnumbered"])
|
163
160
|
end
|
164
161
|
end
|
@@ -169,7 +166,7 @@ module IsoDoc
|
|
169
166
|
next if t["id"].nil? || t["id"].empty?
|
170
167
|
i += 1 unless t["unnumbered"] == "true"
|
171
168
|
@anchors[t["id"]] =
|
172
|
-
anchor_struct("#{num}.#{i}", nil, @
|
169
|
+
anchor_struct("#{num}.#{i}", nil, @labels["admonition"], "box",
|
173
170
|
t["unnumbered"])
|
174
171
|
end
|
175
172
|
end
|
@@ -30,18 +30,16 @@ module Metanorma
|
|
30
30
|
"Metanorma::UN #{Metanorma::UN::VERSION}"
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
Metanorma::UN::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
35
|
-
end
|
36
|
-
|
37
|
-
def output(isodoc_node, outname, format, options={})
|
33
|
+
def output(isodoc_node, inname, outname, format, options={})
|
38
34
|
case format
|
39
35
|
when :html
|
40
|
-
IsoDoc::UN::HtmlConvert.new(options).convert(
|
36
|
+
IsoDoc::UN::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
41
37
|
when :doc
|
42
|
-
IsoDoc::UN::WordConvert.new(options).convert(
|
38
|
+
IsoDoc::UN::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
43
39
|
when :pdf
|
44
|
-
IsoDoc::UN::PdfConvert.new(options).convert(
|
40
|
+
IsoDoc::UN::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
41
|
+
when :presentation
|
42
|
+
IsoDoc::UN::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
45
43
|
else
|
46
44
|
super
|
47
45
|
end
|
data/lib/metanorma/un/version.rb
CHANGED
data/metanorma-unece.gemspec
CHANGED
@@ -26,16 +26,15 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
28
28
|
|
29
|
-
spec.add_dependency "htmlentities", "~> 4.3.4"
|
30
|
-
spec.add_dependency "ruby-jing"
|
31
29
|
spec.add_dependency "roman-numerals"
|
32
30
|
spec.add_dependency "twitter_cldr"
|
33
31
|
spec.add_dependency "iso-639"
|
34
32
|
|
35
|
-
spec.add_dependency "metanorma-standoc", "~> 1.
|
36
|
-
spec.add_dependency "isodoc", "~> 1.
|
33
|
+
spec.add_dependency "metanorma-standoc", "~> 1.5.0"
|
34
|
+
spec.add_dependency "isodoc", "~> 1.2.0"
|
37
35
|
|
38
36
|
spec.add_development_dependency "byebug", "~> 9.1"
|
37
|
+
spec.add_development_dependency "sassc", "2.4.0"
|
39
38
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
40
39
|
spec.add_development_dependency "guard", "~> 2.14"
|
41
40
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-un
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: htmlentities
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 4.3.4
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 4.3.4
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ruby-jing
|
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'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: roman-numerals
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +58,28 @@ dependencies:
|
|
86
58
|
requirements:
|
87
59
|
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
61
|
+
version: 1.5.0
|
90
62
|
type: :runtime
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
66
|
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
68
|
+
version: 1.5.0
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: isodoc
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
73
|
- - "~>"
|
102
74
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
75
|
+
version: 1.2.0
|
104
76
|
type: :runtime
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
80
|
- - "~>"
|
109
81
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
82
|
+
version: 1.2.0
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: byebug
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +94,20 @@ dependencies:
|
|
122
94
|
- - "~>"
|
123
95
|
- !ruby/object:Gem::Version
|
124
96
|
version: '9.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sassc
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.4.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.4.0
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: equivalent-xml
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,17 +259,24 @@ files:
|
|
273
259
|
- lib/isodoc/un/html/html_unece_intro.html
|
274
260
|
- lib/isodoc/un/html/html_unece_plenary_titlepage.html
|
275
261
|
- lib/isodoc/un/html/html_unece_titlepage.html
|
262
|
+
- lib/isodoc/un/html/htmlstyle.css
|
276
263
|
- lib/isodoc/un/html/htmlstyle.scss
|
277
264
|
- lib/isodoc/un/html/logo.jpg
|
278
265
|
- lib/isodoc/un/html/scripts.html
|
266
|
+
- lib/isodoc/un/html/unece.css
|
279
267
|
- lib/isodoc/un/html/unece.scss
|
280
268
|
- lib/isodoc/un/html/word_unece_intro.html
|
281
269
|
- lib/isodoc/un/html/word_unece_plenary_titlepage.html
|
282
270
|
- lib/isodoc/un/html/word_unece_titlepage.html
|
271
|
+
- lib/isodoc/un/html/wordstyle.css
|
283
272
|
- lib/isodoc/un/html/wordstyle.scss
|
284
273
|
- lib/isodoc/un/html_convert.rb
|
274
|
+
- lib/isodoc/un/i18n-en.yaml
|
275
|
+
- lib/isodoc/un/i18n.rb
|
276
|
+
- lib/isodoc/un/init.rb
|
285
277
|
- lib/isodoc/un/metadata.rb
|
286
278
|
- lib/isodoc/un/pdf_convert.rb
|
279
|
+
- lib/isodoc/un/presentation_xml_convert.rb
|
287
280
|
- lib/isodoc/un/un.plenary-attachment.xsl
|
288
281
|
- lib/isodoc/un/un.plenary.xsl
|
289
282
|
- lib/isodoc/un/un.recommendation.xsl
|
@@ -300,7 +293,7 @@ homepage: https://github.com/metanorma/metanorma-un
|
|
300
293
|
licenses:
|
301
294
|
- BSD-2-Clause
|
302
295
|
metadata: {}
|
303
|
-
post_install_message:
|
296
|
+
post_install_message:
|
304
297
|
rdoc_options: []
|
305
298
|
require_paths:
|
306
299
|
- lib
|
@@ -315,9 +308,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
308
|
- !ruby/object:Gem::Version
|
316
309
|
version: '0'
|
317
310
|
requirements: []
|
318
|
-
|
319
|
-
|
320
|
-
signing_key:
|
311
|
+
rubygems_version: 3.0.3
|
312
|
+
signing_key:
|
321
313
|
specification_version: 4
|
322
314
|
summary: Metanorma for UN.
|
323
315
|
test_files: []
|