metanorma-nist 1.0.10 → 1.1.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/converter.rb +13 -18
- data/lib/isodoc/nist/base_convert.rb +25 -3
- data/lib/isodoc/nist/html_convert.rb +0 -4
- data/lib/isodoc/nist/pdf_convert.rb +4 -15
- data/lib/isodoc/nist/presentation_xml_convert.rb +10 -0
- data/lib/isodoc/nist/refs.rb +1 -1
- data/lib/isodoc/nist/section.rb +1 -1
- data/lib/isodoc/nist/word_convert.rb +0 -4
- data/lib/isodoc/nist/{xrefs.rb → xref.rb} +2 -2
- data/lib/metanorma-nist.rb +2 -0
- data/lib/metanorma/nist/processor.rb +6 -4
- data/lib/metanorma/nist/version.rb +1 -1
- data/metanorma-nist.gemspec +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05109623d4ab89934b15717692765c6c29015007695efad9ea8258b81d1e956c'
|
4
|
+
data.tar.gz: f848bb3f40e50382a2bfeca5f2bd89a78d06d7808bbb3aa4e01d3ce88a8cb87e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b3e0c43ab7a515b8dcba5a6c988254d361934a87091dca35a9134b3d51833c463126695bc2ebee8a3c1430b309210fd08adc8efec6e1ddce727dd2a9c96ad28
|
7
|
+
data.tar.gz: edc0d9b4b5aa9b8fe2c98a7369cfec29a44a93a3b4808dfb95b8eb618aa6ff7ada7e0110190bb84cf35355fbcb4497c84827ddbd0eb540aeba2a3389525fd20d
|
@@ -97,21 +97,12 @@ module Asciidoctor
|
|
97
97
|
super
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
filename
|
106
|
-
gsub(%r{^.*/}, "")
|
107
|
-
File.open(filename, "w:UTF-8") { |f| f.write(ret) }
|
108
|
-
html_converter(node).convert filename unless node.attr("nodoc")
|
109
|
-
word_converter(node).convert filename unless node.attr("nodoc")
|
110
|
-
pdf_converter(node)&.convert filename unless node.attr("nodoc")
|
111
|
-
end
|
112
|
-
@log.write(@localdir + @filename + ".err") unless @novalid
|
113
|
-
@files_to_delete.each { |f| FileUtils.rm f }
|
114
|
-
ret
|
100
|
+
def outputs(node, ret)
|
101
|
+
File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
|
102
|
+
presentation_xml_converter(node).convert(@filename + ".xml")
|
103
|
+
html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
|
104
|
+
doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
|
105
|
+
pdf_converter(node)&.convert(@filename + ".presentation.xml", nil, false, "#{@filename}.pdf")
|
115
106
|
end
|
116
107
|
|
117
108
|
def clause_parse(attrs, xml, node)
|
@@ -170,8 +161,8 @@ module Asciidoctor
|
|
170
161
|
xml.annex **attr_code(attrs1) do |xml_section|
|
171
162
|
xml_section.title { |t| t << "Bibliography" }
|
172
163
|
@biblio = true
|
173
|
-
xml.references **attr_code(attrs) do |
|
174
|
-
|
164
|
+
xml.references **attr_code(attrs.merge(normative: true)) do |r|
|
165
|
+
r << node.content
|
175
166
|
end
|
176
167
|
end
|
177
168
|
@biblio = false
|
@@ -203,11 +194,15 @@ module Asciidoctor
|
|
203
194
|
super
|
204
195
|
end
|
205
196
|
|
197
|
+
def presentation_xml_converter(node)
|
198
|
+
IsoDoc::NIST::PresentationXMLConvert.new(html_extract_attributes(node))
|
199
|
+
end
|
200
|
+
|
206
201
|
def html_converter(node)
|
207
202
|
IsoDoc::NIST::HtmlConvert.new(html_extract_attributes(node))
|
208
203
|
end
|
209
204
|
|
210
|
-
def
|
205
|
+
def doc_converter(node)
|
211
206
|
IsoDoc::NIST::WordConvert.new(doc_extract_attributes(node))
|
212
207
|
end
|
213
208
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "isodoc"
|
2
2
|
require_relative "metadata"
|
3
|
-
require_relative "
|
3
|
+
require_relative "xref"
|
4
4
|
require_relative "refs"
|
5
5
|
require_relative "section"
|
6
6
|
require "fileutils"
|
@@ -8,6 +8,14 @@ require "fileutils"
|
|
8
8
|
module IsoDoc
|
9
9
|
module NIST
|
10
10
|
module BaseConvert
|
11
|
+
def metadata_init(lang, script, labels)
|
12
|
+
@meta = Metadata.new(lang, script, labels)
|
13
|
+
end
|
14
|
+
|
15
|
+
def xref_init(lang, script, klass, labels, options)
|
16
|
+
@xrefs = Xref.new(lang, script, klass, labels, options)
|
17
|
+
end
|
18
|
+
|
11
19
|
def keywords(_docxml, out)
|
12
20
|
kw = @meta.get[:keywords]
|
13
21
|
kw.empty? and return
|
@@ -126,8 +134,9 @@ module IsoDoc
|
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
129
|
-
|
130
|
-
"//terms[parent::sections]"
|
137
|
+
def middle_clause
|
138
|
+
"//clause[parent::sections] | //terms[parent::sections]"
|
139
|
+
end
|
131
140
|
|
132
141
|
def middle(isoxml, out)
|
133
142
|
middle_admonitions(isoxml, out)
|
@@ -219,6 +228,19 @@ module IsoDoc
|
|
219
228
|
out << " — "
|
220
229
|
node.at(ns("./p")).children.each { |n| parse(n, out) }
|
221
230
|
end
|
231
|
+
|
232
|
+
def annex_name(annex, name, div)
|
233
|
+
div.h1 **{ class: "Annex" } do |t|
|
234
|
+
t << "#{@xrefs.anchor(annex['id'], :label)} — "
|
235
|
+
t.b do |b|
|
236
|
+
if @bibliographycount == 1 && annex.at(ns("./references"))
|
237
|
+
b << "References"
|
238
|
+
else
|
239
|
+
name&.children&.each { |c2| parse(c2, b) }
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
222
244
|
end
|
223
245
|
end
|
224
246
|
end
|
@@ -37,10 +37,6 @@ module IsoDoc
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
def metadata_init(lang, script, labels)
|
41
|
-
@meta = Metadata.new(lang, script, labels)
|
42
|
-
end
|
43
|
-
|
44
40
|
def googlefonts
|
45
41
|
<<~HEAD.freeze
|
46
42
|
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,600,600i" rel="stylesheet">
|
@@ -7,26 +7,15 @@ module IsoDoc
|
|
7
7
|
module NIST
|
8
8
|
# A {Converter} implementation that generates PDF HTML output, and a
|
9
9
|
# document schema encapsulation of the document for validation
|
10
|
-
class PdfConvert < IsoDoc::
|
10
|
+
class PdfConvert < IsoDoc::XslfoPdfConvert
|
11
11
|
def initialize(options)
|
12
12
|
@libdir = File.dirname(__FILE__)
|
13
13
|
super
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
@series = docxml&.at(ns("//bibdata/series/abbreviation"))&.text
|
20
|
-
/\.xml$/.match(filename) or
|
21
|
-
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
22
|
-
f.write file
|
23
|
-
f.path
|
24
|
-
end
|
25
|
-
FileUtils.rm_rf dir
|
26
|
-
::Metanorma::Output::XslfoPdf.new.convert(
|
27
|
-
filename, outname_html + ".pdf",
|
28
|
-
File.join(@libdir, @series == "NIST CSWP" ?
|
29
|
-
"nist.cswp.xsl" : "nist.sp.xsl"))
|
16
|
+
def pdf_stylesheet(docxml)
|
17
|
+
series = docxml&.at(ns("//bibdata/series/abbreviation"))&.text
|
18
|
+
series == "NIST CSWP" ? "nist.cswp.xsl" : "nist.sp.xsl"
|
30
19
|
end
|
31
20
|
end
|
32
21
|
end
|
data/lib/isodoc/nist/refs.rb
CHANGED
@@ -62,7 +62,7 @@ module IsoDoc
|
|
62
62
|
title = node&.at(ns("./title"))&.text || ""
|
63
63
|
out.div do |div|
|
64
64
|
unless suppress_biblio_title(node)
|
65
|
-
anchor(node['id'], :label, false) and
|
65
|
+
@xrefs.anchor(node['id'], :label, false) and
|
66
66
|
clause_parse_title(node, div, node.at(ns("./title")), out) or
|
67
67
|
div.h2 title, **{ class: "Section3" }
|
68
68
|
end
|
data/lib/isodoc/nist/section.rb
CHANGED
@@ -25,7 +25,7 @@ module IsoDoc
|
|
25
25
|
def preface1(c, title, patent, out)
|
26
26
|
out.div **attr_code(id: c["id"]) do |s|
|
27
27
|
page_break(s) if patent
|
28
|
-
clause_name(anchor(c['id'], :label), title, s,
|
28
|
+
clause_name(@xrefs.anchor(c['id'], :label), title, s,
|
29
29
|
class: (c.name == "executivesummary") ? "NormalTitle" :
|
30
30
|
"IntroTitle")
|
31
31
|
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
@@ -49,10 +49,6 @@ module IsoDoc
|
|
49
49
|
olstyle: "l2" }
|
50
50
|
end
|
51
51
|
|
52
|
-
def metadata_init(lang, script, labels)
|
53
|
-
@meta = Metadata.new(lang, script, labels)
|
54
|
-
end
|
55
|
-
|
56
52
|
def make_body(xml, docxml)
|
57
53
|
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
|
58
54
|
xml.body **body_attr do |body|
|
@@ -4,7 +4,7 @@ require "fileutils"
|
|
4
4
|
|
5
5
|
module IsoDoc
|
6
6
|
module NIST
|
7
|
-
|
7
|
+
class Xref < IsoDoc::Xref
|
8
8
|
SECTIONS_XPATH =
|
9
9
|
"//foreword | //introduction | //reviewnote | //executivesummary | //annex | "\
|
10
10
|
"//sections/clause | //bibliography/references | //acknowledgements | "\
|
@@ -50,7 +50,7 @@ module IsoDoc
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def annex_name_lbl(clause, num)
|
53
|
-
l10n("<b>#{@
|
53
|
+
l10n("<b>#{@labels['annex']} #{num}</b>")
|
54
54
|
end
|
55
55
|
|
56
56
|
def annex_name(annex, name, div)
|
data/lib/metanorma-nist.rb
CHANGED
@@ -3,7 +3,9 @@ require_relative "asciidoctor/nist/converter"
|
|
3
3
|
require_relative "isodoc/nist/html_convert"
|
4
4
|
require_relative "isodoc/nist/pdf_convert"
|
5
5
|
require_relative "isodoc/nist/word_convert"
|
6
|
+
require_relative "isodoc/nist/presentation_xml_convert"
|
6
7
|
require_relative "isodoc/nist/render"
|
8
|
+
require_relative "isodoc/nist/xref"
|
7
9
|
require_relative "metanorma/nist/version"
|
8
10
|
|
9
11
|
if defined? Metanorma
|
@@ -33,14 +33,16 @@ module Metanorma
|
|
33
33
|
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
34
34
|
end
|
35
35
|
|
36
|
-
def output(isodoc_node, outname, format, options={})
|
36
|
+
def output(isodoc_node, inname, outname, format, options={})
|
37
37
|
case format
|
38
38
|
when :html
|
39
|
-
IsoDoc::NIST::HtmlConvert.new(options).convert(
|
39
|
+
IsoDoc::NIST::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
40
40
|
when :doc
|
41
|
-
IsoDoc::NIST::WordConvert.new(options).convert(
|
41
|
+
IsoDoc::NIST::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
42
42
|
when :pdf
|
43
|
-
IsoDoc::NIST::PdfConvert.new(options).convert(
|
43
|
+
IsoDoc::NIST::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
44
|
+
when :presentation
|
45
|
+
IsoDoc::NIST::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
44
46
|
else
|
45
47
|
super
|
46
48
|
end
|
data/metanorma-nist.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "tzinfo-data" # we need this for windows only
|
32
32
|
|
33
33
|
spec.add_dependency "metanorma-standoc", "~> 1.4.0"
|
34
|
-
spec.add_dependency "isodoc", "~> 1.
|
34
|
+
spec.add_dependency "isodoc", "~> 1.1.0"
|
35
35
|
#spec.add_dependency "relaton-nist", "~> 0.3.0"
|
36
36
|
|
37
37
|
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: 1.0
|
4
|
+
version: 1.1.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-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.1.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: 1.
|
110
|
+
version: 1.1.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: byebug
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -298,6 +298,7 @@ files:
|
|
298
298
|
- lib/isodoc/nist/nist.cswp.xsl
|
299
299
|
- lib/isodoc/nist/nist.sp.xsl
|
300
300
|
- lib/isodoc/nist/pdf_convert.rb
|
301
|
+
- lib/isodoc/nist/presentation_xml_convert.rb
|
301
302
|
- lib/isodoc/nist/refs.rb
|
302
303
|
- lib/isodoc/nist/render.rb
|
303
304
|
- lib/isodoc/nist/render_contributors.rb
|
@@ -305,7 +306,7 @@ files:
|
|
305
306
|
- lib/isodoc/nist/section.rb
|
306
307
|
- lib/isodoc/nist/word_convert.rb
|
307
308
|
- lib/isodoc/nist/word_convert_toc.rb
|
308
|
-
- lib/isodoc/nist/
|
309
|
+
- lib/isodoc/nist/xref.rb
|
309
310
|
- lib/metanorma-nist.rb
|
310
311
|
- lib/metanorma/nist.rb
|
311
312
|
- lib/metanorma/nist/processor.rb
|
@@ -315,7 +316,7 @@ homepage: https://github.com/metanorma/metanorma-nist
|
|
315
316
|
licenses:
|
316
317
|
- BSD-2-Clause
|
317
318
|
metadata: {}
|
318
|
-
post_install_message:
|
319
|
+
post_install_message:
|
319
320
|
rdoc_options: []
|
320
321
|
require_paths:
|
321
322
|
- lib
|
@@ -330,9 +331,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
331
|
- !ruby/object:Gem::Version
|
331
332
|
version: '0'
|
332
333
|
requirements: []
|
333
|
-
|
334
|
-
|
335
|
-
signing_key:
|
334
|
+
rubygems_version: 3.0.3
|
335
|
+
signing_key:
|
336
336
|
specification_version: 4
|
337
337
|
summary: Metanorma NIST gem.
|
338
338
|
test_files: []
|