metanorma-nist 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -3
- data/lib/asciidoctor/nist/cleanup.rb +38 -0
- data/lib/asciidoctor/nist/converter.rb +0 -16
- data/lib/asciidoctor/nist/front.rb +9 -9
- data/lib/isodoc/nist/base_convert.rb +4 -3
- data/lib/metanorma/nist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '058ea96daf6a2940d6a1b2b2ddb8464f13a62389c006cfcf423dfa57d5d33c11'
|
4
|
+
data.tar.gz: 47dd1e6208cdf299e9b2146dfe92f0003a66e7b0ca6f169c50dd9a1792627c48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 423c8ba7e534b31b3176e22234937d58a3ae2599e45f0bb476822c05752d4fd9b407df989bba48c19be262c28fcb80fe67df4e107b8632f50fb80ffc9803b8b8
|
7
|
+
data.tar.gz: 9ed5d3661a6804ac4c75a58a2b17effe96115e066d7179bc376a539f097e6249383c1baeed5c26ad4bfddac500142e78741abf8c8030de1ecb69f11c339301a0
|
data/Gemfile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
3
|
|
4
|
-
|
4
|
+
source "https://rubygems.org"
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
5
6
|
|
6
7
|
gemspec
|
8
|
+
|
9
|
+
if File.exist? 'Gemfile.devel'
|
10
|
+
eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
|
11
|
+
end
|
@@ -135,6 +135,44 @@ module Asciidoctor
|
|
135
135
|
end
|
136
136
|
ret
|
137
137
|
end
|
138
|
+
|
139
|
+
TERM_CLAUSE = "//sections/terms | "\
|
140
|
+
"//sections/clause[descendant::terms] | "\
|
141
|
+
"//annex/terms | "\
|
142
|
+
"//annex/clause[descendant::terms] ".freeze
|
143
|
+
|
144
|
+
def boilerplate_cleanup(xmldoc)
|
145
|
+
isodoc = IsoDoc::Convert.new({})
|
146
|
+
@lang = xmldoc&.at("//bibdata/language")&.text
|
147
|
+
@script = xmldoc&.at("//bibdata/script")&.text
|
148
|
+
isodoc.i18n_init(@lang, @script)
|
149
|
+
f = xmldoc.at(self.class::TERM_CLAUSE) and
|
150
|
+
term_defs_boilerplate(f.at("../title"),
|
151
|
+
xmldoc.xpath(".//termdocsource"),
|
152
|
+
f.at(".//term"), f.at(".//p"), isodoc)
|
153
|
+
end
|
154
|
+
|
155
|
+
def sort_biblio(bib)
|
156
|
+
@citation_order = {}
|
157
|
+
bib.document.xpath("//xref | //origin").each_with_index do |x, i|
|
158
|
+
cit = x["target"] || x["bibitemid"]
|
159
|
+
next unless refid? cit
|
160
|
+
@citation_order[cit] ||= i
|
161
|
+
end
|
162
|
+
bib.sort do |a, b|
|
163
|
+
sort_biblio_key(a) <=> sort_biblio_key(b)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# if numeric citation, order by appearance. if alphanumeric, sort alphabetically
|
168
|
+
def sort_biblio_key(bib)
|
169
|
+
if metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text&.gsub(%r{[\[\]]}, "")
|
170
|
+
key = /^\[\d+\]$/.match(metaid) ? ( @citation_order[metaid] % "09%d" ) : metaid
|
171
|
+
end
|
172
|
+
title = bib&.at("./title[@type = 'main']")&.text ||
|
173
|
+
bib&.at("./title")&.text || bib&.at("./formattedref")&.text
|
174
|
+
"#{key} :: #{title}"
|
175
|
+
end
|
138
176
|
end
|
139
177
|
end
|
140
178
|
end
|
@@ -237,22 +237,6 @@ module Asciidoctor
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
-
TERM_CLAUSE = "//sections/terms | "\
|
241
|
-
"//sections/clause[descendant::terms] | "\
|
242
|
-
"//annex/terms | "\
|
243
|
-
"//annex/clause[descendant::terms] ".freeze
|
244
|
-
|
245
|
-
def boilerplate_cleanup(xmldoc)
|
246
|
-
isodoc = IsoDoc::Convert.new({})
|
247
|
-
@lang = xmldoc&.at("//bibdata/language")&.text
|
248
|
-
@script = xmldoc&.at("//bibdata/script")&.text
|
249
|
-
isodoc.i18n_init(@lang, @script)
|
250
|
-
f = xmldoc.at(self.class::TERM_CLAUSE) and
|
251
|
-
term_defs_boilerplate(f.at("../title"),
|
252
|
-
xmldoc.xpath(".//termdocsource"),
|
253
|
-
f.at(".//term"), f.at(".//p"), isodoc)
|
254
|
-
end
|
255
|
-
|
256
240
|
NIST_PREFIX_REFS = "SP|FIPS"
|
257
241
|
|
258
242
|
def refitem(xml, item, node)
|
@@ -26,28 +26,28 @@ module Asciidoctor
|
|
26
26
|
def title_subtitle(node, t, at)
|
27
27
|
return unless node.attr("title-sub")
|
28
28
|
t.title(**attr_code(at.merge(type: "subtitle"))) do |t1|
|
29
|
-
t1 << asciidoc_sub(node.attr("title-sub"))
|
29
|
+
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
|
30
30
|
end
|
31
31
|
node.attr("title-sub-short") and
|
32
32
|
t.title(**attr_code(at.merge(type: "short-subtitle"))) do |t1|
|
33
|
-
t1 << asciidoc_sub(node.attr("title-sub-short"))
|
33
|
+
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub-short"))
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def title_document_class(node, t, at)
|
38
38
|
return unless node.attr("title-document-class")
|
39
39
|
t.title(**attr_code(at.merge(type: "document-class"))) do |t1|
|
40
|
-
t1 << asciidoc_sub(node.attr("title-document-class"))
|
40
|
+
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-document-class"))
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def title_main(node, t, at)
|
45
45
|
t.title(**attr_code(at.merge(type: "main"))) do |t1|
|
46
|
-
t1 << asciidoc_sub(node.attr("title-main") || node.title)
|
46
|
+
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main") || node.title)
|
47
47
|
end
|
48
48
|
node.attr("title-main-short") and
|
49
49
|
t.title(**attr_code(at.merge(type: "short-title"))) do |t1|
|
50
|
-
t1 << asciidoc_sub(node.attr("title-main-short"))
|
50
|
+
t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main-short"))
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -263,16 +263,16 @@ module Asciidoctor
|
|
263
263
|
|
264
264
|
def metadata_superseding_titles(b, node)
|
265
265
|
if node.attr("superseding-title")
|
266
|
-
b.title asciidoc_sub(node.attr("superseding-title")),
|
266
|
+
b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-title")),
|
267
267
|
**{ type: "main" }
|
268
268
|
node.attr("superseding-subtitle") and
|
269
|
-
b.title asciidoc_sub(node.attr("superseding-subtitle")),
|
269
|
+
b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-subtitle")),
|
270
270
|
**{ type: "subtitle" }
|
271
271
|
else
|
272
|
-
b.title asciidoc_sub(node.attr("title-main") || node.title),
|
272
|
+
b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main") || node.title),
|
273
273
|
**{ type: "main" }
|
274
274
|
node.attr("title-sub") and
|
275
|
-
b.title asciidoc_sub(node.attr("title-sub")), **{ type: "subtitle" }
|
275
|
+
b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub")), **{ type: "subtitle" }
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
@@ -251,13 +251,14 @@ module IsoDoc
|
|
251
251
|
end
|
252
252
|
|
253
253
|
def reference_format(b, r)
|
254
|
-
|
255
|
-
|
254
|
+
id = bibitem_ref_code(b)
|
255
|
+
code = render_identifier(id)
|
256
|
+
if id["type"] == "metanorma"
|
256
257
|
r << "[#{code}] "
|
257
258
|
insert_tab(r, 1)
|
258
259
|
end
|
259
260
|
reference_format1(b, r)
|
260
|
-
r << " [#{code}] " unless
|
261
|
+
r << " [#{code}] " unless id["type"] == "metanorma"
|
261
262
|
end
|
262
263
|
|
263
264
|
def reference_format1(b, r)
|
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.2.
|
4
|
+
version: 0.2.2
|
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-09-
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|