metanorma-mpfd 0.3.21 → 0.3.23
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/.travis.yml +17 -0
- data/Gemfile +1 -8
- data/README.adoc +1 -96
- data/lib/asciidoctor/mpfd/biblio.rng +166 -567
- data/lib/asciidoctor/mpfd/converter.rb +84 -7
- data/lib/asciidoctor/mpfd/isodoc.rng +727 -763
- data/lib/asciidoctor/mpfd/isostandard.rng +1054 -0
- data/lib/asciidoctor/mpfd/mpfd.rng +145 -11
- data/lib/asciidoctor/mpfd/pdf.js +31 -0
- data/lib/asciidoctor/mpfd/section.rb +51 -23
- data/lib/asciidoctor/mpfd.rb +1 -0
- data/lib/isodoc/mpfd/html/header.html +6 -64
- data/lib/isodoc/mpfd/html/html_rsd_titlepage.html +4 -4
- data/lib/isodoc/mpfd/html/htmlstyle.scss +505 -200
- data/lib/isodoc/mpfd/html/rsd.scss +30 -149
- data/lib/isodoc/mpfd/html/scripts.html +27 -25
- data/lib/isodoc/mpfd/html/scripts.pdf.html +70 -0
- data/lib/isodoc/mpfd/html/word_rsd_titlepage.html +2 -2
- data/lib/isodoc/mpfd/html/wordstyle.scss +9 -61
- data/lib/isodoc/mpfd/html_convert.rb +258 -4
- data/lib/isodoc/mpfd/i18n-en.yaml +0 -1
- data/lib/isodoc/mpfd/metadata.rb +32 -8
- data/lib/isodoc/mpfd/{base_convert.rb → pdf_convert.rb} +137 -40
- data/lib/isodoc/mpfd/word_convert.rb +292 -4
- data/lib/metanorma/mpfd/processor.rb +4 -8
- data/lib/metanorma/mpfd/version.rb +1 -1
- data/lib/metanorma-mpfd.rb +1 -0
- data/metanorma-mpfd.gemspec +8 -7
- metadata +66 -33
- data/.github/workflows/macos.yml +0 -39
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -41
- data/.hound.yml +0 -3
- data/.rubocop.yml +0 -10
- data/lib/asciidoctor/mpfd/basicdoc.rng +0 -1059
- data/lib/asciidoctor/mpfd/reqt.rng +0 -171
- data/lib/asciidoctor/mpfd/validate.rb +0 -30
- data/lib/isodoc/mpfd/i18n-zh-Hans.yaml +0 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
require_relative "base_convert"
|
|
2
1
|
require "isodoc"
|
|
2
|
+
require_relative "metadata"
|
|
3
|
+
require "fileutils"
|
|
3
4
|
|
|
4
5
|
module IsoDoc
|
|
5
6
|
module Mpfd
|
|
@@ -11,10 +12,12 @@ module IsoDoc
|
|
|
11
12
|
def initialize(options)
|
|
12
13
|
@libdir = File.dirname(__FILE__)
|
|
13
14
|
super
|
|
15
|
+
FileUtils.cp html_doc_path("logo.jpg"), "logo.jpg"
|
|
16
|
+
FileUtils.cp html_doc_path('mpfa-logo-no-text@4x.png'), "mpfa-logo-no-text@4x.png"
|
|
17
|
+
@files_to_delete << "logo.jpg"
|
|
18
|
+
@files_to_delete << "mpfa-logo-no-text@4x.png"
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
include BaseConvert
|
|
17
|
-
|
|
18
21
|
def default_fonts(options)
|
|
19
22
|
{
|
|
20
23
|
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Titillium Web",sans-serif'),
|
|
@@ -32,11 +35,26 @@ module IsoDoc
|
|
|
32
35
|
}
|
|
33
36
|
end
|
|
34
37
|
|
|
35
|
-
def
|
|
38
|
+
def metadata_init(lang, script, labels)
|
|
39
|
+
@meta = Metadata.new(lang, script, labels)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def html_head
|
|
36
43
|
<<~HEAD.freeze
|
|
44
|
+
<title>{{ doctitle }}</title>
|
|
45
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
46
|
+
|
|
47
|
+
<!--TOC script import-->
|
|
48
|
+
<script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
|
|
49
|
+
|
|
50
|
+
<!--Google fonts-->
|
|
37
51
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
|
|
38
52
|
<link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
|
|
39
53
|
<link href="https://fonts.googleapis.com/css?family=Titillium+Web:400,400i,700,700i" rel="stylesheet">
|
|
54
|
+
<!--Font awesome import for the link icon-->
|
|
55
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
|
|
56
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
|
|
57
|
+
<style class="anchorjs"></style>
|
|
40
58
|
HEAD
|
|
41
59
|
end
|
|
42
60
|
|
|
@@ -49,6 +67,102 @@ module IsoDoc
|
|
|
49
67
|
end
|
|
50
68
|
end
|
|
51
69
|
|
|
70
|
+
def html_toc(docxml)
|
|
71
|
+
docxml
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def annex_name(annex, name, div)
|
|
75
|
+
div.h1 **{ class: "Annex" } do |t|
|
|
76
|
+
t << "#{get_anchors[annex['id']][:label]} "
|
|
77
|
+
t.b do |b|
|
|
78
|
+
name&.children&.each { |c2| parse(c2, b) }
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def pre_parse(node, out)
|
|
84
|
+
out.pre node.text # content.gsub(/</, "<").gsub(/>/, ">")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def term_defs_boilerplate(div, source, term, preface)
|
|
88
|
+
if source.empty? && term.nil?
|
|
89
|
+
div << @no_terms_boilerplate
|
|
90
|
+
else
|
|
91
|
+
div << term_defs_boilerplate_cont(source, term)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def error_parse(node, out)
|
|
96
|
+
# catch elements not defined in ISO
|
|
97
|
+
case node.name
|
|
98
|
+
when "pre"
|
|
99
|
+
pre_parse(node, out)
|
|
100
|
+
when "keyword"
|
|
101
|
+
out.span node.text, **{ class: "keyword" }
|
|
102
|
+
else
|
|
103
|
+
super
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def fileloc(loc)
|
|
108
|
+
File.join(File.dirname(__FILE__), loc)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def info(isoxml, out)
|
|
112
|
+
@meta.security isoxml, out
|
|
113
|
+
super
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def i18n_init(lang, script)
|
|
117
|
+
super
|
|
118
|
+
y = if lang == "en"
|
|
119
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
|
|
120
|
+
elsif lang == "zh" && script == "Hans"
|
|
121
|
+
YAML.load_file(File.join(File.dirname(__FILE__),
|
|
122
|
+
"i18n-zh-Hans.yaml"))
|
|
123
|
+
else
|
|
124
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
|
|
125
|
+
end
|
|
126
|
+
@annex_lbl = "Appendix"
|
|
127
|
+
@labels = @labels.merge(y)
|
|
128
|
+
@clause_lbl = y["clause"]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def terms_defs_title(f)
|
|
132
|
+
return f&.at(ns("./title"))&.content
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
TERM_CLAUSE = "//preface/terms | "\
|
|
136
|
+
"//preface/clause[descendant::terms]".freeze
|
|
137
|
+
|
|
138
|
+
def terms_defs(isoxml, out, num)
|
|
139
|
+
f = isoxml.at(ns(TERM_CLAUSE)) or return num
|
|
140
|
+
out.div **attr_code(id: f["id"]) do |div|
|
|
141
|
+
clause_name(nil, terms_defs_title(f), div, nil)
|
|
142
|
+
f.elements.each do |e|
|
|
143
|
+
parse(e, div) unless %w{title source}.include? e.name
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
num
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
FRONT_CLAUSE = "//*[parent::preface]".freeze
|
|
150
|
+
|
|
151
|
+
def preface(isoxml, out)
|
|
152
|
+
isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
|
|
153
|
+
if c.name == "terms" then terms_defs isoxml, out, 0
|
|
154
|
+
else
|
|
155
|
+
out.div **attr_code(id: c["id"]) do |s|
|
|
156
|
+
clause_name(get_anchors[c['id']][:label],
|
|
157
|
+
c&.at(ns("./title"))&.content, s, nil)
|
|
158
|
+
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
|
159
|
+
parse(c1, s)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
52
166
|
def make_body3(body, docxml)
|
|
53
167
|
body.div **{ class: "main-section" } do |div3|
|
|
54
168
|
preface docxml, div3
|
|
@@ -57,6 +171,146 @@ module IsoDoc
|
|
|
57
171
|
comments div3
|
|
58
172
|
end
|
|
59
173
|
end
|
|
174
|
+
|
|
175
|
+
def middle(isoxml, out)
|
|
176
|
+
middle_title(out)
|
|
177
|
+
clause isoxml, out
|
|
178
|
+
annex isoxml, out
|
|
179
|
+
bibliography isoxml, out
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def termdef_parse(node, out)
|
|
183
|
+
set_termdomain("")
|
|
184
|
+
node.children.each { |n| parse(n, out) }
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def initial_anchor_names(d)
|
|
188
|
+
d.xpath(ns(FRONT_CLAUSE)).each do |c|
|
|
189
|
+
preface_names(c)
|
|
190
|
+
sequential_asset_names(c)
|
|
191
|
+
end
|
|
192
|
+
middle_section_asset_names(d)
|
|
193
|
+
clause_names(d, 0)
|
|
194
|
+
termnote_anchor_names(d)
|
|
195
|
+
termexample_anchor_names(d)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def annex_name_lbl(clause, num)
|
|
199
|
+
l10n("<b>#{@annex_lbl} #{num}</b>")
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def xclause_names(docxml, _sect_num)
|
|
203
|
+
q = "//clause[parent::sections]"
|
|
204
|
+
@topnum = nil
|
|
205
|
+
docxml.xpath(ns(q)).each do |c|
|
|
206
|
+
section_names(c, @topnum, 1)
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def clause_names(docxml, sect_num)
|
|
211
|
+
q = "//clause[parent::sections]"
|
|
212
|
+
@topnum = nil
|
|
213
|
+
lvl = 0
|
|
214
|
+
docxml.xpath(ns(q)).each do |c|
|
|
215
|
+
container_names(c, 0)
|
|
216
|
+
sect_num, lvl = sect_names(c, nil, sect_num, 0, lvl)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def container_names(clause, lvl)
|
|
221
|
+
if clause["container"]
|
|
222
|
+
@anchors[clause["id"]] =
|
|
223
|
+
{ label: nil, xref: clause.at(ns("./title"))&.text, level: lvl+1 }
|
|
224
|
+
end
|
|
225
|
+
clause.xpath(ns("./clause | ./term | ./terms | "\
|
|
226
|
+
"./definitions")).each do |c|
|
|
227
|
+
container_names(c, clause["container"] ? lvl+1 : lvl)
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def sect_names(clause, num, i, lvl, prev_lvl)
|
|
232
|
+
return i if clause.nil?
|
|
233
|
+
curr = i
|
|
234
|
+
if clause["container"]
|
|
235
|
+
retlvl = lvl+1
|
|
236
|
+
else
|
|
237
|
+
retlvl = lvl
|
|
238
|
+
i+=1
|
|
239
|
+
curr = i
|
|
240
|
+
name = num.nil? ? i.to_s : "#{num}.#{i}"
|
|
241
|
+
@anchors[clause["id"]] = { label: name, xref: l10n("#{@clause_lbl} #{name}"), level: lvl+1 }
|
|
242
|
+
end
|
|
243
|
+
prev = lvl
|
|
244
|
+
j = 0
|
|
245
|
+
clause.xpath(ns("./clause | ./term | ./terms | "\
|
|
246
|
+
"./definitions")).each do |c|
|
|
247
|
+
if clause["container"]
|
|
248
|
+
i, lvl = sect_names(c, num, i, lvl, lvl)
|
|
249
|
+
else
|
|
250
|
+
j, prev = sect_names(c, name, j, lvl+1, prev)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
i = j if j >0
|
|
254
|
+
i = curr if lvl < prev
|
|
255
|
+
[i, prev]
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def annex_naming(c, num, lvl, i)
|
|
259
|
+
if c["guidance"] then annex_names1(c, "#{num}E", lvl + 1)
|
|
260
|
+
else
|
|
261
|
+
i+= 1
|
|
262
|
+
annex_names1(c, "#{num}.#{i}", lvl + 1)
|
|
263
|
+
end
|
|
264
|
+
i
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def annex_names(clause, num)
|
|
268
|
+
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
|
|
269
|
+
xref: "#{@annex_lbl} #{num}", level: 1 }
|
|
270
|
+
i = 0
|
|
271
|
+
clause.xpath(ns("./clause")).each do |c|
|
|
272
|
+
i = annex_naming(c, num, 1, i)
|
|
273
|
+
end
|
|
274
|
+
hierarchical_asset_names(clause, num)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def annex_names1(clause, num, level)
|
|
278
|
+
@anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
|
|
279
|
+
level: level }
|
|
280
|
+
i = 0
|
|
281
|
+
clause.xpath(ns("./clause")).each do |c|
|
|
282
|
+
i = annex_naming(c, num, level, i)
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def clause(isoxml, out)
|
|
287
|
+
isoxml.xpath(ns(MIDDLE_CLAUSE)).each do |c|
|
|
288
|
+
out.div **attr_code(id: c["id"]) do |s|
|
|
289
|
+
clause_name(get_anchors[c['id']][:label],
|
|
290
|
+
c&.at(ns("./title"))&.content, s, class: c["container"] ? "containerhdr" : nil )
|
|
291
|
+
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
|
292
|
+
parse(c1, s)
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def clause_parse_title(node, div, c1, out)
|
|
299
|
+
if node["inline-header"] == "true"
|
|
300
|
+
inline_header_title(out, node, c1)
|
|
301
|
+
else
|
|
302
|
+
attrs = { class: node["container"] ? "containerhdr" : nil }
|
|
303
|
+
div.send "h#{get_anchors[node['id']][:level]}", **attr_code(attrs) do |h|
|
|
304
|
+
lbl = get_anchors[node['id']][:label]
|
|
305
|
+
h << "#{lbl}. " if lbl && !@suppressheadingnumbers
|
|
306
|
+
c1&.children&.each { |c2| parse(c2, h) }
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def ol_depth(node)
|
|
312
|
+
ol_style(node["type"])
|
|
313
|
+
end
|
|
60
314
|
end
|
|
61
315
|
end
|
|
62
316
|
end
|
data/lib/isodoc/mpfd/metadata.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require "isodoc"
|
|
2
|
-
require "twitter_cldr"
|
|
3
2
|
require 'date'
|
|
4
3
|
|
|
5
4
|
module IsoDoc
|
|
@@ -8,8 +7,7 @@ module IsoDoc
|
|
|
8
7
|
class Metadata < IsoDoc::Metadata
|
|
9
8
|
def initialize(lang, script, labels)
|
|
10
9
|
super
|
|
11
|
-
|
|
12
|
-
set(:logo, File.expand_path(File.join(here, "html", "mpfa-logo-no-text@4x.png")))
|
|
10
|
+
# set(:status, "")
|
|
13
11
|
end
|
|
14
12
|
|
|
15
13
|
def title(isoxml, _out)
|
|
@@ -28,18 +26,29 @@ module IsoDoc
|
|
|
28
26
|
|
|
29
27
|
def docid(isoxml, _out)
|
|
30
28
|
docnumber = isoxml.at(ns("//bibdata/docidentifier"))
|
|
31
|
-
|
|
29
|
+
docstatus = isoxml.at(ns("//bibdata/status"))
|
|
30
|
+
dn = docnumber&.text
|
|
31
|
+
if docstatus
|
|
32
|
+
set(:status, status_print(docstatus.text))
|
|
33
|
+
abbr = status_abbr(docstatus.text)
|
|
34
|
+
dn = "#{dn}(#{abbr})" unless abbr.empty?
|
|
35
|
+
end
|
|
36
|
+
set(:docnumber, dn)
|
|
32
37
|
end
|
|
33
38
|
|
|
34
39
|
def doctype(isoxml, _out)
|
|
35
|
-
b = isoxml
|
|
36
|
-
return unless b
|
|
37
|
-
t = b.split(/[- ]/).
|
|
40
|
+
b = isoxml.at(ns("//bibdata")) || return
|
|
41
|
+
return unless b["type"]
|
|
42
|
+
t = b["type"].split(/[- ]/).
|
|
38
43
|
map{ |w| w.capitalize unless w == "MPF" }.join(" ")
|
|
39
44
|
set(:doctype, t)
|
|
40
45
|
end
|
|
41
46
|
|
|
42
|
-
def
|
|
47
|
+
def status_print(status)
|
|
48
|
+
status.split(/-/).map{ |w| w.capitalize }.join(" ")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def status_abbr(status)
|
|
43
52
|
case status
|
|
44
53
|
when "working-draft" then "wd"
|
|
45
54
|
when "committee-draft" then "cd"
|
|
@@ -51,6 +60,10 @@ module IsoDoc
|
|
|
51
60
|
|
|
52
61
|
def version(isoxml, _out)
|
|
53
62
|
super
|
|
63
|
+
|
|
64
|
+
revdate = get[:revdate]
|
|
65
|
+
set(:revdate_monthyear, monthyr(revdate))
|
|
66
|
+
|
|
54
67
|
edition = isoxml.at(ns("//version/edition"))
|
|
55
68
|
if edition
|
|
56
69
|
set(
|
|
@@ -60,6 +73,12 @@ module IsoDoc
|
|
|
60
73
|
split(/(\W)/).map(&:capitalize).join
|
|
61
74
|
)
|
|
62
75
|
end
|
|
76
|
+
|
|
77
|
+
puts "get get[:docstage] #{get[:docstage]}"
|
|
78
|
+
puts get[:docstage]
|
|
79
|
+
if get[:docstage] == "95" and get[:docsubstage] == "99"
|
|
80
|
+
set(:draftinfo, "(Repealed)")
|
|
81
|
+
end
|
|
63
82
|
end
|
|
64
83
|
|
|
65
84
|
def monthyr(isodate)
|
|
@@ -69,6 +88,11 @@ module IsoDoc
|
|
|
69
88
|
# invalid dates get thrown
|
|
70
89
|
isodate
|
|
71
90
|
end
|
|
91
|
+
|
|
92
|
+
def security(isoxml, _out)
|
|
93
|
+
security = isoxml.at(ns("//bibdata/security")) || return
|
|
94
|
+
set(:security, security.text)
|
|
95
|
+
end
|
|
72
96
|
end
|
|
73
97
|
end
|
|
74
98
|
end
|
|
@@ -1,27 +1,116 @@
|
|
|
1
1
|
require "isodoc"
|
|
2
2
|
require_relative "metadata"
|
|
3
|
-
require
|
|
3
|
+
require "fileutils"
|
|
4
4
|
|
|
5
5
|
module IsoDoc
|
|
6
6
|
module Mpfd
|
|
7
|
-
|
|
7
|
+
# A {Converter} implementation that generates PDF HTML output, and a
|
|
8
|
+
# document schema encapsulation of the document for validation
|
|
9
|
+
class PdfConvert < IsoDoc::PdfConvert
|
|
10
|
+
def initialize(options)
|
|
11
|
+
@libdir = File.dirname(__FILE__)
|
|
12
|
+
super
|
|
13
|
+
FileUtils.cp html_doc_path("logo.jpg"), "logo.jpg"
|
|
14
|
+
FileUtils.cp html_doc_path('mpfa-logo-no-text@4x.png'), "mpfa-logo-no-text@4x.png"
|
|
15
|
+
@files_to_delete << "logo.jpg"
|
|
16
|
+
@files_to_delete << "mpfa-logo-no-text@4x.png"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def default_fonts(options)
|
|
20
|
+
{
|
|
21
|
+
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Titillium Web",sans-serif'),
|
|
22
|
+
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Titillium Web",sans-serif'),
|
|
23
|
+
monospacefont: '"Space Mono",monospace'
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def default_file_locations(_options)
|
|
28
|
+
{
|
|
29
|
+
htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
|
30
|
+
htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
|
|
31
|
+
htmlintropage: html_doc_path("html_rsd_intro.html"),
|
|
32
|
+
scripts_pdf: html_doc_path("scripts.pdf.html"),
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
8
36
|
def metadata_init(lang, script, labels)
|
|
9
37
|
@meta = Metadata.new(lang, script, labels)
|
|
10
38
|
end
|
|
11
39
|
|
|
40
|
+
def html_head()
|
|
41
|
+
<<~HEAD.freeze
|
|
42
|
+
<title>{{ doctitle }}</title>
|
|
43
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
44
|
+
|
|
45
|
+
<!--TOC script import-->
|
|
46
|
+
<script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
|
|
47
|
+
|
|
48
|
+
<!--Google fonts-->
|
|
49
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
|
|
50
|
+
<link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
|
|
51
|
+
<link href="https://fonts.googleapis.com/css?family=Titillium+Web:400,400i,700,700i" rel="stylesheet">
|
|
52
|
+
<!--Font awesome import for the link icon-->
|
|
53
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
|
|
54
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
|
|
55
|
+
<style class="anchorjs"></style>
|
|
56
|
+
HEAD
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def make_body(xml, docxml)
|
|
60
|
+
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
|
|
61
|
+
xml.body **body_attr do |body|
|
|
62
|
+
make_body1(body, docxml)
|
|
63
|
+
make_body2(body, docxml)
|
|
64
|
+
make_body3(body, docxml)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def html_toc(docxml)
|
|
69
|
+
docxml
|
|
70
|
+
end
|
|
71
|
+
|
|
12
72
|
def annex_name(annex, name, div)
|
|
13
73
|
div.h1 **{ class: "Annex" } do |t|
|
|
14
|
-
t << "#{
|
|
74
|
+
t << "#{get_anchors[annex['id']][:label]} "
|
|
15
75
|
t.b do |b|
|
|
16
76
|
name&.children&.each { |c2| parse(c2, b) }
|
|
17
77
|
end
|
|
18
78
|
end
|
|
19
79
|
end
|
|
20
80
|
|
|
81
|
+
def pre_parse(node, out)
|
|
82
|
+
out.pre node.text # content.gsub(/</, "<").gsub(/>/, ">")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def term_defs_boilerplate(div, source, term, preface)
|
|
86
|
+
if source.empty? && term.nil?
|
|
87
|
+
div << @no_terms_boilerplate
|
|
88
|
+
else
|
|
89
|
+
div << term_defs_boilerplate_cont(source, term)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def error_parse(node, out)
|
|
94
|
+
# catch elements not defined in ISO
|
|
95
|
+
case node.name
|
|
96
|
+
when "pre"
|
|
97
|
+
pre_parse(node, out)
|
|
98
|
+
when "keyword"
|
|
99
|
+
out.span node.text, **{ class: "keyword" }
|
|
100
|
+
else
|
|
101
|
+
super
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
21
105
|
def fileloc(loc)
|
|
22
106
|
File.join(File.dirname(__FILE__), loc)
|
|
23
107
|
end
|
|
24
108
|
|
|
109
|
+
def info(isoxml, out)
|
|
110
|
+
@meta.security isoxml, out
|
|
111
|
+
super
|
|
112
|
+
end
|
|
113
|
+
|
|
25
114
|
def i18n_init(lang, script)
|
|
26
115
|
super
|
|
27
116
|
y = if lang == "en"
|
|
@@ -30,10 +119,10 @@ module IsoDoc
|
|
|
30
119
|
YAML.load_file(File.join(File.dirname(__FILE__),
|
|
31
120
|
"i18n-zh-Hans.yaml"))
|
|
32
121
|
else
|
|
33
|
-
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-
|
|
122
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
|
|
34
123
|
end
|
|
124
|
+
@annex_lbl = "Appendix"
|
|
35
125
|
@labels = @labels.merge(y)
|
|
36
|
-
@annex_lbl = y["annex"]
|
|
37
126
|
@clause_lbl = y["clause"]
|
|
38
127
|
end
|
|
39
128
|
|
|
@@ -44,13 +133,9 @@ module IsoDoc
|
|
|
44
133
|
TERM_CLAUSE = "//preface/terms | "\
|
|
45
134
|
"//preface/clause[descendant::terms]".freeze
|
|
46
135
|
|
|
47
|
-
SECTIONS_XPATH =
|
|
48
|
-
"//foreword | //introduction | //preface/terms | //preface/clause | //annex | "\
|
|
49
|
-
"//sections/clause | //bibliography/references | //acknowledgements | "\
|
|
50
|
-
"//bibliography/clause".freeze
|
|
51
136
|
|
|
52
137
|
def terms_defs(isoxml, out, num)
|
|
53
|
-
f = isoxml.at(ns(
|
|
138
|
+
f = isoxml.at(ns(TERM_CLAUSE)) or return num
|
|
54
139
|
out.div **attr_code(id: f["id"]) do |div|
|
|
55
140
|
clause_name(nil, terms_defs_title(f), div, nil)
|
|
56
141
|
f.elements.each do |e|
|
|
@@ -61,13 +146,14 @@ module IsoDoc
|
|
|
61
146
|
end
|
|
62
147
|
|
|
63
148
|
FRONT_CLAUSE = "//*[parent::preface]".freeze
|
|
149
|
+
#FRONT_CLAUSE = "//clause[parent::preface] | //terms[parent::preface]".freeze
|
|
64
150
|
|
|
65
151
|
def preface(isoxml, out)
|
|
66
|
-
isoxml.xpath(ns(
|
|
67
|
-
if c.name == "terms"
|
|
152
|
+
isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
|
|
153
|
+
if c.name == "terms" then terms_defs isoxml, out, 0
|
|
68
154
|
else
|
|
69
155
|
out.div **attr_code(id: c["id"]) do |s|
|
|
70
|
-
clause_name(
|
|
156
|
+
clause_name(get_anchors[c['id']][:label],
|
|
71
157
|
c&.at(ns("./title"))&.content, s, nil)
|
|
72
158
|
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
|
73
159
|
parse(c1, s)
|
|
@@ -77,20 +163,17 @@ module IsoDoc
|
|
|
77
163
|
end
|
|
78
164
|
end
|
|
79
165
|
|
|
80
|
-
def
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
166
|
+
def make_body3(body, docxml)
|
|
167
|
+
body.div **{ class: "main-section" } do |div3|
|
|
168
|
+
preface docxml, div3
|
|
169
|
+
middle docxml, div3
|
|
170
|
+
footnotes div3
|
|
171
|
+
comments div3
|
|
84
172
|
end
|
|
85
|
-
middle_section_asset_names(d)
|
|
86
|
-
clause_names(d, 0)
|
|
87
|
-
termnote_anchor_names(d)
|
|
88
|
-
termexample_anchor_names(d)
|
|
89
173
|
end
|
|
90
174
|
|
|
91
175
|
def middle(isoxml, out)
|
|
92
176
|
middle_title(out)
|
|
93
|
-
middle_admonitions(isoxml, out)
|
|
94
177
|
clause isoxml, out
|
|
95
178
|
annex isoxml, out
|
|
96
179
|
bibliography isoxml, out
|
|
@@ -101,6 +184,21 @@ module IsoDoc
|
|
|
101
184
|
node.children.each { |n| parse(n, out) }
|
|
102
185
|
end
|
|
103
186
|
|
|
187
|
+
def initial_anchor_names(d)
|
|
188
|
+
#preface_names(d.at(ns("//foreword")))
|
|
189
|
+
#preface_names(d.at(ns("//introduction")))
|
|
190
|
+
#preface_names(d.at(ns("//preface/terms | "\
|
|
191
|
+
#"//preface/clause[descendant::terms]")))
|
|
192
|
+
d.xpath(ns(FRONT_CLAUSE)).each do |c|
|
|
193
|
+
preface_names(c)
|
|
194
|
+
sequential_asset_names(c)
|
|
195
|
+
end
|
|
196
|
+
middle_section_asset_names(d)
|
|
197
|
+
clause_names(d, 0)
|
|
198
|
+
termnote_anchor_names(d)
|
|
199
|
+
termexample_anchor_names(d)
|
|
200
|
+
end
|
|
201
|
+
|
|
104
202
|
def annex_name_lbl(clause, num)
|
|
105
203
|
l10n("<b>#{@annex_lbl} #{num}</b>")
|
|
106
204
|
end
|
|
@@ -117,7 +215,7 @@ module IsoDoc
|
|
|
117
215
|
|
|
118
216
|
def container_names(clause, lvl)
|
|
119
217
|
if clause["container"]
|
|
120
|
-
@anchors[clause["id"]] =
|
|
218
|
+
@anchors[clause["id"]] =
|
|
121
219
|
{ label: nil, xref: clause.at(ns("./title"))&.text, level: lvl+1 }
|
|
122
220
|
end
|
|
123
221
|
clause.xpath(ns("./clause | ./term | ./terms | "\
|
|
@@ -129,7 +227,9 @@ module IsoDoc
|
|
|
129
227
|
def sect_names(clause, num, i, lvl, prev_lvl)
|
|
130
228
|
return i if clause.nil?
|
|
131
229
|
curr = i
|
|
132
|
-
if
|
|
230
|
+
if clause["container"]
|
|
231
|
+
retlvl = lvl+1
|
|
232
|
+
else
|
|
133
233
|
retlvl = lvl
|
|
134
234
|
i+=1
|
|
135
235
|
curr = i
|
|
@@ -154,7 +254,7 @@ module IsoDoc
|
|
|
154
254
|
def annex_naming(c, num, lvl, i)
|
|
155
255
|
if c["guidance"] then annex_names1(c, "#{num}E", lvl + 1)
|
|
156
256
|
else
|
|
157
|
-
i+= 1
|
|
257
|
+
i+= 1
|
|
158
258
|
annex_names1(c, "#{num}.#{i}", lvl + 1)
|
|
159
259
|
end
|
|
160
260
|
i
|
|
@@ -163,31 +263,26 @@ module IsoDoc
|
|
|
163
263
|
def annex_names(clause, num)
|
|
164
264
|
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
|
|
165
265
|
xref: "#{@annex_lbl} #{num}", level: 1 }
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
i = 0
|
|
170
|
-
clause.xpath(ns("./clause | ./references")).each do |c|
|
|
171
|
-
container_names(c, 0)
|
|
172
|
-
i = annex_naming(c, num, 1, i)
|
|
173
|
-
end
|
|
266
|
+
i = 0
|
|
267
|
+
clause.xpath(ns("./clause")).each do |c|
|
|
268
|
+
i = annex_naming(c, num, 1, i)
|
|
174
269
|
end
|
|
175
270
|
hierarchical_asset_names(clause, num)
|
|
176
271
|
end
|
|
177
272
|
|
|
178
273
|
def annex_names1(clause, num, level)
|
|
179
|
-
|
|
180
|
-
|
|
274
|
+
@anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
|
|
275
|
+
level: level }
|
|
181
276
|
i = 0
|
|
182
|
-
clause.xpath(ns("./clause
|
|
277
|
+
clause.xpath(ns("./clause")).each do |c|
|
|
183
278
|
i = annex_naming(c, num, level, i)
|
|
184
279
|
end
|
|
185
280
|
end
|
|
186
281
|
|
|
187
282
|
def clause(isoxml, out)
|
|
188
|
-
isoxml.xpath(ns(
|
|
283
|
+
isoxml.xpath(ns(MIDDLE_CLAUSE)).each do |c|
|
|
189
284
|
out.div **attr_code(id: c["id"]) do |s|
|
|
190
|
-
clause_name(
|
|
285
|
+
clause_name(get_anchors[c['id']][:label],
|
|
191
286
|
c&.at(ns("./title"))&.content, s, class: c["container"] ? "containerhdr" : nil )
|
|
192
287
|
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
|
193
288
|
parse(c1, s)
|
|
@@ -201,8 +296,8 @@ module IsoDoc
|
|
|
201
296
|
inline_header_title(out, node, c1)
|
|
202
297
|
else
|
|
203
298
|
attrs = { class: node["container"] ? "containerhdr" : nil }
|
|
204
|
-
div.send "h#{
|
|
205
|
-
lbl =
|
|
299
|
+
div.send "h#{get_anchors[node['id']][:level]}", **attr_code(attrs) do |h|
|
|
300
|
+
lbl = get_anchors[node['id']][:label]
|
|
206
301
|
h << "#{lbl}. " if lbl && !@suppressheadingnumbers
|
|
207
302
|
c1&.children&.each { |c2| parse(c2, h) }
|
|
208
303
|
end
|
|
@@ -212,6 +307,8 @@ module IsoDoc
|
|
|
212
307
|
def ol_depth(node)
|
|
213
308
|
ol_style(node["type"])
|
|
214
309
|
end
|
|
310
|
+
|
|
215
311
|
end
|
|
216
312
|
end
|
|
217
313
|
end
|
|
314
|
+
|