metanorma-nist 0.1.5 → 0.2.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/nist/reqt.rng +1 -1
- data/lib/isodoc/nist/base_convert.rb +25 -109
- data/lib/isodoc/nist/html_convert.rb +18 -6
- data/lib/isodoc/nist/xrefs.rb +106 -0
- data/lib/metanorma/nist/version.rb +1 -1
- data/metanorma-nist.gemspec +3 -3
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53bb2d233e8d14f8dea275aec0532f9c6d91e2248f7f1128b89850f666201d50
|
4
|
+
data.tar.gz: 3c39f1c061185dbf87e0ef8c66d477effa41e3b7694fd7bf1bf4ad57112746fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a64e2d06c7cb26477e6dd86df42e64b1b3800858429c2c1fe42ed6a3f73d709114bb81d80b9b94845fa9a7c3c15ef40685620d67c3f019ea2ed9d0f9a4b508e
|
7
|
+
data.tar.gz: 239c4c3d89d8a6031e06e726f390b00eaebcf2d0fe9bbf3a7609e6a6cc0cd3af4b89db345b915680a67b6eb5115e41cff8789403e39cb35abe7954051dccf245
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "isodoc"
|
2
2
|
require_relative "metadata"
|
3
|
+
require_relative "xrefs"
|
3
4
|
require "fileutils"
|
4
5
|
|
5
6
|
module IsoDoc
|
@@ -60,10 +61,6 @@ module IsoDoc
|
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
63
|
-
def i18n_init(lang, script)
|
64
|
-
super
|
65
|
-
end
|
66
|
-
|
67
64
|
def fileloc(loc)
|
68
65
|
File.join(File.dirname(__FILE__), loc)
|
69
66
|
end
|
@@ -156,29 +153,29 @@ module IsoDoc
|
|
156
153
|
end
|
157
154
|
|
158
155
|
def errata_head(t)
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
156
|
+
t.thead do |h|
|
157
|
+
h.tr do |tr|
|
158
|
+
%w(Date Type Change Pages).each do |hdr|
|
159
|
+
tr.th hdr
|
164
160
|
end
|
165
161
|
end
|
162
|
+
end
|
166
163
|
end
|
167
164
|
|
168
165
|
def errata_body(t, node)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
166
|
+
t.tbody do |b|
|
167
|
+
node.xpath(ns("./row")).each do |row|
|
168
|
+
b.tr do |tr|
|
169
|
+
%w{date type change pages}.each do |hdr|
|
170
|
+
tr.td do |td|
|
171
|
+
row&.at(ns("./#{hdr}"))&.children.each do |n|
|
172
|
+
parse(n, td)
|
177
173
|
end
|
178
174
|
end
|
179
175
|
end
|
180
176
|
end
|
181
177
|
end
|
178
|
+
end
|
182
179
|
end
|
183
180
|
|
184
181
|
MIDDLE_CLAUSE = "//clause[parent::sections] | "\
|
@@ -200,50 +197,6 @@ module IsoDoc
|
|
200
197
|
super
|
201
198
|
end
|
202
199
|
|
203
|
-
SECTIONS_XPATH =
|
204
|
-
"//foreword | //introduction | //reviewnote | //executivesummary | //annex | "\
|
205
|
-
"//sections/clause | //bibliography/references | "\
|
206
|
-
"//bibliography/clause".freeze
|
207
|
-
|
208
|
-
def initial_anchor_names(d)
|
209
|
-
d.xpath("//xmlns:boilerplate/child::* | //xmlns:preface/child::*").each do |c|
|
210
|
-
preface_names(c)
|
211
|
-
end
|
212
|
-
@in_execsummary = true
|
213
|
-
hierarchical_asset_names(d.xpath("//xmlns:executivesummary"), "ES")
|
214
|
-
@in_execsummary = false
|
215
|
-
clause_names(d, 0)
|
216
|
-
middle_section_asset_names(d)
|
217
|
-
termnote_anchor_names(d)
|
218
|
-
termexample_anchor_names(d)
|
219
|
-
end
|
220
|
-
|
221
|
-
def back_anchor_names(docxml)
|
222
|
-
docxml.xpath(ns("//annex")).each_with_index do |c, i|
|
223
|
-
annex_names(c, (65 + i).chr.to_s)
|
224
|
-
end
|
225
|
-
docxml.xpath(ns("//bibliography/clause | "\
|
226
|
-
"//bibliography/references")).each do |b|
|
227
|
-
preface_names(b)
|
228
|
-
end
|
229
|
-
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
|
230
|
-
reference_names(ref)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
def middle_section_asset_names(d)
|
235
|
-
middle_sections = "//xmlns:preface/child::*[not(self::xmlns:executivesummary)] | "\
|
236
|
-
"//xmlns:sections/child::*"
|
237
|
-
sequential_asset_names(d.xpath(middle_sections))
|
238
|
-
end
|
239
|
-
|
240
|
-
def clause_names(docxml, sect_num)
|
241
|
-
q = "//xmlns:sections/child::*"
|
242
|
-
docxml.xpath(q).each_with_index do |c, i|
|
243
|
-
section_names(c, (i + sect_num), 1)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
200
|
def get_linkend(node)
|
248
201
|
link = anchor_linkend(node, docid_l10n(node["target"] || "[#{node['citeas']}]"))
|
249
202
|
link += eref_localities(node.xpath(ns("./locality")), link)
|
@@ -264,47 +217,6 @@ module IsoDoc
|
|
264
217
|
super.merge(y)
|
265
218
|
end
|
266
219
|
|
267
|
-
def annex_name_lbl(clause, num)
|
268
|
-
l10n("<b>#{@annex_lbl} #{num}</b>")
|
269
|
-
end
|
270
|
-
|
271
|
-
def annex_name(annex, name, div)
|
272
|
-
div.h1 **{ class: "Annex" } do |t|
|
273
|
-
t << "#{anchor(annex['id'], :label)} — "
|
274
|
-
t.b do |b|
|
275
|
-
if @bibliographycount == 1 && annex.at(ns("./references"))
|
276
|
-
b << "References"
|
277
|
-
else
|
278
|
-
name&.children&.each { |c2| parse(c2, b) }
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
def hiersep
|
285
|
-
"-"
|
286
|
-
end
|
287
|
-
|
288
|
-
def annex_names(clause, num)
|
289
|
-
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
|
290
|
-
xref: "#{@annex_lbl} #{num}", level: 1 }
|
291
|
-
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
292
|
-
annex_names1(c, "#{num}.#{i + 1}", 2)
|
293
|
-
end
|
294
|
-
clause.xpath(ns("./terms | ./term | ./references")).each_with_index do |c, i|
|
295
|
-
annex_names1(c, "#{num}", 1)
|
296
|
-
end
|
297
|
-
hierarchical_asset_names(clause, num)
|
298
|
-
end
|
299
|
-
|
300
|
-
def annex_names1(clause, num, level)
|
301
|
-
@anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
|
302
|
-
level: level, type: "clause" }
|
303
|
-
clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
|
304
|
-
annex_names1(c, "#{num}.#{i + 1}", level + 1)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
220
|
def terms_parse(node, out)
|
309
221
|
out.div **attr_code(id: node["id"]) do |div|
|
310
222
|
node.at(ns("./title")) and
|
@@ -334,7 +246,7 @@ module IsoDoc
|
|
334
246
|
"organization[abbreviation = 'NIST' or xmlns:name = 'NIST']".freeze
|
335
247
|
|
336
248
|
# we are taking the ref number/code out as prefix to reference
|
337
|
-
def
|
249
|
+
def nonstd_bibitem(list, b, ordinal, bibliography)
|
338
250
|
list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
|
339
251
|
if !b.at(ns("./formattedref"))
|
340
252
|
nist_reference_format(b, r)
|
@@ -344,18 +256,22 @@ module IsoDoc
|
|
344
256
|
end
|
345
257
|
end
|
346
258
|
|
259
|
+
def std_bibitem_entry(list, b, ordinal, biblio)
|
260
|
+
nonstd_bibitem(list, b, ordinal, biblio)
|
261
|
+
end
|
262
|
+
|
347
263
|
def reference_format(b, r)
|
348
|
-
code =
|
349
|
-
if /^\
|
350
|
-
r << "#{code} "
|
264
|
+
code = bibitem_ref_code(b)
|
265
|
+
if /^\d+$/.match(code)
|
266
|
+
r << "[#{code}] "
|
351
267
|
insert_tab(r, 1)
|
352
268
|
end
|
353
269
|
reference_format1(b, r)
|
354
|
-
r << " [#{code}] " unless /^\
|
270
|
+
r << " [#{code}] " unless /^\d+$/.match(code)
|
355
271
|
end
|
356
272
|
|
357
273
|
def reference_format1(b, r)
|
358
|
-
|
274
|
+
if ftitle = b.at(ns("./formattedref"))
|
359
275
|
ftitle&.children&.each { |n| parse(n, r) }
|
360
276
|
else
|
361
277
|
title = b.at(ns("./title[@language = '#{@language}']")) || b.at(ns("./title"))
|
@@ -367,7 +283,7 @@ module IsoDoc
|
|
367
283
|
|
368
284
|
def omit_docid_prefix(prefix)
|
369
285
|
return true if prefix.nil? || prefix.empty?
|
370
|
-
|
286
|
+
super || prefix == "NIST"
|
371
287
|
end
|
372
288
|
|
373
289
|
def nist_reference_format(b, r)
|
@@ -52,13 +52,25 @@ module IsoDoc
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def toclevel
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
ret = toclevel_classes.map { |l| "#{l}:not(:empty):not(.TermNum):not(.noTOC):not(.AbstractTitle):not(.IntroTitle):not(.ForewordTitle)" }
|
56
|
+
<<~HEAD.freeze
|
57
|
+
function toclevel() { return "#{ret.join(',')}";}
|
58
|
+
HEAD
|
59
|
+
end
|
60
|
+
|
61
|
+
def html_toc(docxml)
|
62
|
+
idx = docxml.at("//div[@id = 'toc']") or return docxml
|
63
|
+
toc = "<ul>"
|
64
|
+
path = toclevel_classes.map do |l|
|
65
|
+
"//main//#{l}[not(@class = 'TermNum')][not(@class = 'noTOC')][not(text())][not(@class = 'AbstractTitle')][not(@class = 'IntroTitle')][not(@class = 'ForewordTitle')]"
|
66
|
+
end
|
67
|
+
docxml.xpath(path.join(" | ")).each_with_index do |h, tocidx|
|
68
|
+
h["id"] ||= "toc#{tocidx}"
|
69
|
+
toc += html_toc_entry(h.name, h)
|
61
70
|
end
|
71
|
+
idx.children = "#{toc}</ul>"
|
72
|
+
docxml
|
73
|
+
end
|
62
74
|
|
63
75
|
def make_body(xml, docxml)
|
64
76
|
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
require_relative "metadata"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
module NIST
|
7
|
+
module BaseConvert
|
8
|
+
SECTIONS_XPATH =
|
9
|
+
"//foreword | //introduction | //reviewnote | //executivesummary | //annex | "\
|
10
|
+
"//sections/clause | //bibliography/references | "\
|
11
|
+
"//bibliography/clause".freeze
|
12
|
+
|
13
|
+
def initial_anchor_names(d)
|
14
|
+
d.xpath("//xmlns:boilerplate/child::* | //xmlns:preface/child::*").each do |c|
|
15
|
+
preface_names(c)
|
16
|
+
end
|
17
|
+
@in_execsummary = true
|
18
|
+
hierarchical_asset_names(d.xpath("//xmlns:executivesummary"), "ES")
|
19
|
+
@in_execsummary = false
|
20
|
+
clause_names(d, 0)
|
21
|
+
middle_section_asset_names(d)
|
22
|
+
termnote_anchor_names(d)
|
23
|
+
termexample_anchor_names(d)
|
24
|
+
end
|
25
|
+
|
26
|
+
def back_anchor_names(docxml)
|
27
|
+
docxml.xpath(ns("//annex")).each_with_index do |c, i|
|
28
|
+
annex_names(c, (65 + i).chr.to_s)
|
29
|
+
end
|
30
|
+
docxml.xpath(ns("//bibliography/clause | "\
|
31
|
+
"//bibliography/references")).each do |b|
|
32
|
+
preface_names(b)
|
33
|
+
end
|
34
|
+
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
|
35
|
+
reference_names(ref)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def middle_section_asset_names(d)
|
40
|
+
middle_sections = "//xmlns:preface/child::*[not(self::xmlns:executivesummary)] | "\
|
41
|
+
"//xmlns:sections/child::*"
|
42
|
+
sequential_asset_names(d.xpath(middle_sections))
|
43
|
+
end
|
44
|
+
|
45
|
+
def clause_names(docxml, sect_num)
|
46
|
+
q = "//xmlns:sections/child::*"
|
47
|
+
docxml.xpath(q).each_with_index do |c, i|
|
48
|
+
section_names(c, (i + sect_num), 1)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def annex_name_lbl(clause, num)
|
53
|
+
l10n("<b>#{@annex_lbl} #{num}</b>")
|
54
|
+
end
|
55
|
+
|
56
|
+
def annex_name(annex, name, div)
|
57
|
+
div.h1 **{ class: "Annex" } do |t|
|
58
|
+
t << "#{anchor(annex['id'], :label)} — "
|
59
|
+
t.b do |b|
|
60
|
+
if @bibliographycount == 1 && annex.at(ns("./references"))
|
61
|
+
b << "References"
|
62
|
+
else
|
63
|
+
name&.children&.each { |c2| parse(c2, b) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def hiersep
|
70
|
+
"-"
|
71
|
+
end
|
72
|
+
|
73
|
+
def annex_names(clause, num)
|
74
|
+
@anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
|
75
|
+
xref: "#{@annex_lbl} #{num}", level: 1 }
|
76
|
+
clause.xpath(ns("./clause")).each_with_index do |c, i|
|
77
|
+
annex_names1(c, "#{num}.#{i + 1}", 2)
|
78
|
+
end
|
79
|
+
clause.xpath(ns("./terms | ./term | ./references")).each_with_index do |c, i|
|
80
|
+
annex_names1(c, "#{num}", 1)
|
81
|
+
end
|
82
|
+
hierarchical_asset_names(clause, num)
|
83
|
+
end
|
84
|
+
|
85
|
+
def annex_names1(clause, num, level)
|
86
|
+
@anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
|
87
|
+
level: level, type: "clause" }
|
88
|
+
clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
|
89
|
+
annex_names1(c, "#{num}.#{i + 1}", level + 1)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def terms_parse(node, out)
|
94
|
+
out.div **attr_code(id: node["id"]) do |div|
|
95
|
+
node.at(ns("./title")) and
|
96
|
+
clause_parse_title(node, div, node.at(ns("./title")), out)
|
97
|
+
term_defs_boilerplate(div, node.xpath(ns(".//termdocsource")),
|
98
|
+
node.at(ns(".//term")), node.at(ns("./p")))
|
99
|
+
node.elements.each do |e|
|
100
|
+
parse(e, div) unless %w{title source}.include? e.name
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/metanorma-nist.gemspec
CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency "twitter_cldr"
|
31
31
|
spec.add_dependency "tzinfo-data" # we need this for windows only
|
32
32
|
|
33
|
-
spec.add_dependency "metanorma-standoc", "~> 1.
|
34
|
-
spec.add_dependency "isodoc", "~> 0.
|
35
|
-
spec.add_dependency "relaton-nist", "~> 0.3.0"
|
33
|
+
spec.add_dependency "metanorma-standoc", "~> 1.3.0"
|
34
|
+
spec.add_dependency "isodoc", "~> 1.0.0"
|
35
|
+
#spec.add_dependency "relaton-nist", "~> 0.3.0"
|
36
36
|
|
37
37
|
spec.add_development_dependency "bundler", "~> 2.0.1"
|
38
38
|
spec.add_development_dependency "byebug", "~> 9.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-nist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -86,42 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
89
|
+
version: 1.3.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
96
|
+
version: 1.3.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isodoc
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 1.0.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: relaton-nist
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.3.0
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.3.0
|
110
|
+
version: 1.0.0
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: bundler
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -330,6 +316,7 @@ files:
|
|
330
316
|
- lib/isodoc/nist/pdf_convert.rb
|
331
317
|
- lib/isodoc/nist/render.rb
|
332
318
|
- lib/isodoc/nist/word_convert.rb
|
319
|
+
- lib/isodoc/nist/xrefs.rb
|
333
320
|
- lib/metanorma-nist.rb
|
334
321
|
- lib/metanorma/nist.rb
|
335
322
|
- lib/metanorma/nist/processor.rb
|