metanorma-un 0.3.4 → 0.3.9
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 +10 -10
- data/.github/workflows/ubuntu.yml +25 -11
- data/.github/workflows/windows.yml +11 -12
- data/README.adoc +2 -2
- data/lib/asciidoctor/un/biblio.rng +131 -46
- data/lib/asciidoctor/un/boilerplate.xml +1 -1
- data/lib/asciidoctor/un/converter.rb +21 -5
- data/lib/asciidoctor/un/isodoc.rng +32 -4
- data/lib/asciidoctor/un/un.rng +107 -1
- data/lib/isodoc/un/base_convert.rb +1 -170
- data/lib/isodoc/un/html/html_unece_plenary_titlepage.html +7 -15
- data/lib/isodoc/un/html/html_unece_titlepage.html +1 -2
- data/lib/isodoc/un/html/htmlstyle.scss +191 -137
- data/lib/isodoc/un/html/scripts.html +14 -27
- data/lib/isodoc/un/html/word_unece_plenary_titlepage.html +113 -65
- data/lib/isodoc/un/html_convert.rb +3 -3
- data/lib/isodoc/un/metadata.rb +3 -30
- data/lib/isodoc/un/pdf_convert.rb +13 -115
- data/lib/isodoc/un/un.plenary.xsl +3621 -0
- data/lib/isodoc/un/un.recommendation.xsl +13050 -0
- data/lib/isodoc/un/word_convert.rb +1 -0
- data/lib/isodoc/un/xref.rb +188 -0
- data/lib/metanorma/un/processor.rb +8 -0
- data/lib/metanorma/un/version.rb +1 -1
- metadata +5 -3
- data/lib/isodoc/un/html/scripts.pdf.html +0 -72
@@ -0,0 +1,188 @@
|
|
1
|
+
require "roman-numerals"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
module UN
|
5
|
+
module BaseConvert
|
6
|
+
MIDDLE_CLAUSE = "//clause[parent::sections]".freeze
|
7
|
+
|
8
|
+
def initial_anchor_names(d)
|
9
|
+
preface_names(d.at(ns("//preface/abstract")))
|
10
|
+
preface_names(d.at(ns("//foreword")))
|
11
|
+
preface_names(d.at(ns("//introduction")))
|
12
|
+
d.xpath(ns("//preface/clause")).each do |c|
|
13
|
+
preface_names(c)
|
14
|
+
end
|
15
|
+
preface_names(d.at(ns("//acknowledgements")))
|
16
|
+
sequential_asset_names(
|
17
|
+
d.xpath(ns("//preface/abstract | //foreword | //introduction | "\
|
18
|
+
"//preface/clause | //acknowledgements")))
|
19
|
+
middle_section_asset_names(d)
|
20
|
+
clause_names(d, 0)
|
21
|
+
termnote_anchor_names(d)
|
22
|
+
termexample_anchor_names(d)
|
23
|
+
end
|
24
|
+
|
25
|
+
def clause_names(docxml, sect_num)
|
26
|
+
q = "//clause[parent::sections]"
|
27
|
+
@paranumber = 0
|
28
|
+
docxml.xpath(ns(q)).each_with_index do |c, i|
|
29
|
+
section_names(c, (i + sect_num), 1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def levelnumber(num, lvl)
|
34
|
+
case lvl % 3
|
35
|
+
when 1 then RomanNumerals.to_roman(num)
|
36
|
+
when 2 then ("A".ord + num - 1).chr
|
37
|
+
when 0 then num.to_s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def annex_levelnum(num, lvl)
|
42
|
+
case lvl % 3
|
43
|
+
when 0 then RomanNumerals.to_roman(num)
|
44
|
+
when 1 then ("A".ord + num - 1).chr
|
45
|
+
when 2 then num.to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
NONTERMINAL =
|
50
|
+
"./clause | ./term | ./terms | ./definitions | ./references".freeze
|
51
|
+
|
52
|
+
def leaf_section?(clause)
|
53
|
+
!clause.at(ns(NONTERMINAL)) &&
|
54
|
+
!%w(definitions annex terms).include?(clause.name) &&
|
55
|
+
clause.at(ns("./p | ./bibitem"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def label_leaf_section(clause, lvl)
|
59
|
+
@paranumber += 1
|
60
|
+
@anchors[clause["id"]] = {label: @paranumber.to_s,
|
61
|
+
xref: "paragraph #{@paranumber}",
|
62
|
+
level: lvl, type: "paragraph" }
|
63
|
+
end
|
64
|
+
|
65
|
+
def label_annex_leaf_section(clause, num, lvl)
|
66
|
+
@paranumber += 1
|
67
|
+
@anchors[clause["id"]] = {label: @paranumber.to_s,
|
68
|
+
xref: "paragraph #{num}.#{@paranumber}",
|
69
|
+
level: lvl, type: "paragraph" }
|
70
|
+
end
|
71
|
+
|
72
|
+
def section_names(clause, num, lvl)
|
73
|
+
return num if clause.nil?
|
74
|
+
leaf_section?(clause) and label_leaf_section(clause, lvl) and return
|
75
|
+
num = num + 1
|
76
|
+
lbl = levelnumber(num, 1)
|
77
|
+
@anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
|
78
|
+
xref: l10n("#{@clause_lbl} #{lbl}") }
|
79
|
+
i = 1
|
80
|
+
clause.xpath(ns(NONTERMINAL)).each do |c|
|
81
|
+
next if c["unnumbered"] == "true"
|
82
|
+
section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
|
83
|
+
i += 1 if !leaf_section?(c)
|
84
|
+
end
|
85
|
+
num
|
86
|
+
end
|
87
|
+
|
88
|
+
def section_names1(clause, num, level)
|
89
|
+
leaf_section?(clause) and label_leaf_section(clause, level) and return
|
90
|
+
/\.(?<leafnum>[^.]+$)/ =~ num
|
91
|
+
@anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
|
92
|
+
xref: l10n("#{@clause_lbl} #{num}") }
|
93
|
+
i = 1
|
94
|
+
clause.xpath(ns(NONTERMINAL)).each do |c|
|
95
|
+
next if c["unnumbered"] == "true"
|
96
|
+
section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
|
97
|
+
i += 1 if !leaf_section?(c)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def annex_name_lbl(clause, num)
|
102
|
+
l10n("<b>#{@annex_lbl} #{num}</b>")
|
103
|
+
end
|
104
|
+
|
105
|
+
SUBCLAUSES =
|
106
|
+
"./clause | ./references | ./term | ./terms | ./definitions".freeze
|
107
|
+
|
108
|
+
|
109
|
+
def annex_names(clause, num)
|
110
|
+
hierarchical_asset_names(clause, num)
|
111
|
+
leaf_section?(clause) and
|
112
|
+
label_annex_leaf_section(clause, num, 1) and return
|
113
|
+
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
|
114
|
+
type: "clause",
|
115
|
+
xref: "#{@annex_lbl} #{num}", level: 1 }
|
116
|
+
if a = single_annex_special_section(clause)
|
117
|
+
annex_names1(a, "#{num}", 1)
|
118
|
+
else
|
119
|
+
i = 1
|
120
|
+
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
121
|
+
next if c["unnumbered"] == "true"
|
122
|
+
annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
|
123
|
+
i += 1 if !leaf_section?(c)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def annex_names1(clause, num, level)
|
129
|
+
leaf_section?(clause) and
|
130
|
+
label_annex_leaf_section(clause, num, level) and return
|
131
|
+
/\.(?<leafnum>[^.]+$)/ =~ num
|
132
|
+
@anchors[clause["id"]] = { label: leafnum, xref: "#{@annex_lbl} #{num}",
|
133
|
+
level: level, type: "clause" }
|
134
|
+
i = 1
|
135
|
+
clause.xpath(ns("./clause | ./references")).each do |c|
|
136
|
+
next if c["unnumbered"] == "true"
|
137
|
+
annex_names1(c, "#{num}.#{annex_levelnum(i, level + 1)}", level + 1)
|
138
|
+
i += 1 if !leaf_section?(c)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def back_anchor_names(docxml)
|
143
|
+
docxml.xpath(ns("//annex")).each_with_index do |c, i|
|
144
|
+
@paranumber = 0
|
145
|
+
annex_names(c, RomanNumerals.to_roman(i + 1))
|
146
|
+
end
|
147
|
+
docxml.xpath(ns("//bibliography/clause |"\
|
148
|
+
"//bibliography/references")).each do |b|
|
149
|
+
preface_names(b)
|
150
|
+
end
|
151
|
+
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
|
152
|
+
reference_names(ref)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def sequential_admonition_names(clause)
|
157
|
+
i = 0
|
158
|
+
clause.xpath(ns(".//admonition")).each do |t|
|
159
|
+
next if t["id"].nil? || t["id"].empty?
|
160
|
+
i += 1 unless t["unnumbered"] == "true"
|
161
|
+
@anchors[t["id"]] = anchor_struct(i.to_s, nil, @admonition_lbl,
|
162
|
+
"box", t["unnumbered"])
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def hierarchical_admonition_names(clause, num)
|
167
|
+
i = 0
|
168
|
+
clause.xpath(ns(".//admonition")).each do |t|
|
169
|
+
next if t["id"].nil? || t["id"].empty?
|
170
|
+
i += 1 unless t["unnumbered"] == "true"
|
171
|
+
@anchors[t["id"]] =
|
172
|
+
anchor_struct("#{num}.#{i}", nil, @admonition_lbl, "box",
|
173
|
+
t["unnumbered"])
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def sequential_asset_names(clause)
|
178
|
+
super
|
179
|
+
sequential_admonition_names(clause)
|
180
|
+
end
|
181
|
+
|
182
|
+
def hierarchical_asset_names(clause, num)
|
183
|
+
super
|
184
|
+
hierarchical_admonition_names(clause, num)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -2,6 +2,14 @@ require "metanorma/processor"
|
|
2
2
|
|
3
3
|
module Metanorma
|
4
4
|
module UN
|
5
|
+
def self.fonts_used
|
6
|
+
{
|
7
|
+
html: ["Arial", "Arial Black", "Courier", "Times New Roman", "HanSans"],
|
8
|
+
doc: ["Arial", "Arial Black", "Courier", "Times New Roman", "HanSans"],
|
9
|
+
pdf: ["Arial", "Arial Black", "Courier", "Times New Roman", "HanSans"],
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
5
13
|
class Processor < Metanorma::Processor
|
6
14
|
|
7
15
|
def initialize
|
data/lib/metanorma/un/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-un
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
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-
|
11
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -276,7 +276,6 @@ files:
|
|
276
276
|
- lib/isodoc/un/html/htmlstyle.scss
|
277
277
|
- lib/isodoc/un/html/logo.jpg
|
278
278
|
- lib/isodoc/un/html/scripts.html
|
279
|
-
- lib/isodoc/un/html/scripts.pdf.html
|
280
279
|
- lib/isodoc/un/html/unece.scss
|
281
280
|
- lib/isodoc/un/html/word_unece_intro.html
|
282
281
|
- lib/isodoc/un/html/word_unece_plenary_titlepage.html
|
@@ -285,7 +284,10 @@ files:
|
|
285
284
|
- lib/isodoc/un/html_convert.rb
|
286
285
|
- lib/isodoc/un/metadata.rb
|
287
286
|
- lib/isodoc/un/pdf_convert.rb
|
287
|
+
- lib/isodoc/un/un.plenary.xsl
|
288
|
+
- lib/isodoc/un/un.recommendation.xsl
|
288
289
|
- lib/isodoc/un/word_convert.rb
|
290
|
+
- lib/isodoc/un/xref.rb
|
289
291
|
- lib/metanorma-un.rb
|
290
292
|
- lib/metanorma/un.rb
|
291
293
|
- lib/metanorma/un/UN_emblem_blue.svg
|
@@ -1,72 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
//TOC generation
|
3
|
-
$('#toc').toc({
|
4
|
-
'selectors': toclevel(), //elements to use as headings
|
5
|
-
'container': 'main', //element to find all selectors in
|
6
|
-
'smoothScrolling': true, //enable or disable smooth scrolling on click
|
7
|
-
'prefix': 'toc', //prefix for anchor tags and class names
|
8
|
-
'onHighlight': function(el) {}, //called when a new section is highlighted
|
9
|
-
'highlightOnScroll': false, //add class to heading that is currently in focus
|
10
|
-
'highlightOffset': 100, //offset to trigger the next headline
|
11
|
-
'anchorName': function(i, heading, prefix) { //custom function for anchor name
|
12
|
-
return prefix+i;
|
13
|
-
},
|
14
|
-
'headerText': function(i, heading, $heading) { //custom function building the header-item text
|
15
|
-
return $heading.text();
|
16
|
-
},
|
17
|
-
'itemClass': function(i, heading, $heading, prefix) { // custom function for item class
|
18
|
-
return $heading[0].tagName.toLowerCase();
|
19
|
-
}
|
20
|
-
});
|
21
|
-
|
22
|
-
</script>
|
23
|
-
|
24
|
-
<script>
|
25
|
-
//TOC toggle animation
|
26
|
-
$('#toggle').on('click', function(){
|
27
|
-
if( $('nav').is(':visible') ) {
|
28
|
-
$('nav').animate({ 'left': '-353px' }, 'slow', function(){
|
29
|
-
$('nav').hide();
|
30
|
-
});
|
31
|
-
$('.container').animate({ 'padding-left': '31px' }, 'slow');
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
$('nav').show();
|
35
|
-
$('nav').animate({ 'left': '0px' }, 'slow');
|
36
|
-
$('.container').animate({ 'padding-left': '360px' }, 'slow');
|
37
|
-
}
|
38
|
-
});
|
39
|
-
</script>
|
40
|
-
|
41
|
-
<script>
|
42
|
-
// Scroll to top button
|
43
|
-
window.onscroll = function() {scrollFunction()};
|
44
|
-
|
45
|
-
function scrollFunction() {
|
46
|
-
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
|
47
|
-
document.getElementById("myBtn").style.display = "block";
|
48
|
-
} else {
|
49
|
-
document.getElementById("myBtn").style.display = "none";
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
// When the user clicks on the button, scroll to the top of the document
|
54
|
-
function topFunction() {
|
55
|
-
document.body.scrollTop = 0;
|
56
|
-
document.documentElement.scrollTop = 0;
|
57
|
-
}
|
58
|
-
</script>
|
59
|
-
|
60
|
-
<script>
|
61
|
-
/*
|
62
|
-
$(document).ready(function() {
|
63
|
-
$('[id^=toc]').each(function ()
|
64
|
-
{
|
65
|
-
var currentToc = $(this);
|
66
|
-
var url = window.location.href;
|
67
|
-
currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
|
68
|
-
});
|
69
|
-
});
|
70
|
-
*/
|
71
|
-
</script>
|
72
|
-
|