metanorma-nist 1.0.5 → 1.0.6
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 +0 -7
- data/.github/workflows/ubuntu.yml +2 -9
- data/.github/workflows/windows.yml +0 -8
- data/lib/asciidoctor/nist/biblio.rng +53 -26
- data/lib/asciidoctor/nist/converter.rb +2 -1
- data/lib/asciidoctor/nist/front.rb +14 -9
- data/lib/asciidoctor/nist/isodoc.rng +28 -1
- data/lib/isodoc/nist/base_convert.rb +1 -1
- data/lib/isodoc/nist/common.xsl +1246 -0
- data/lib/isodoc/nist/html/scripts.html +4 -20
- data/lib/isodoc/nist/nist.cswp.xsl +3804 -0
- data/lib/isodoc/nist/nist.sp.xsl +4672 -0
- data/lib/isodoc/nist/pdf_convert.rb +13 -146
- data/lib/metanorma/nist/version.rb +1 -1
- metadata +5 -2
@@ -13,154 +13,21 @@ module IsoDoc
|
|
13
13
|
super
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def default_fonts(options)
|
26
|
-
{
|
27
|
-
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Libre Baskerville",serif'),
|
28
|
-
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Libre Baskerville",serif'),
|
29
|
-
monospacefont: '"Space Mono",monospace'
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def default_file_locations(_options)
|
34
|
-
{
|
35
|
-
htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
36
|
-
htmlcoverpage: html_doc_path("html_nist_titlepage.html"),
|
37
|
-
htmlintropage: html_doc_path("html_nist_intro.html"),
|
38
|
-
scripts_pdf: html_doc_path("scripts.pdf.html"),
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
def metadata_init(lang, script, labels)
|
43
|
-
@meta = Metadata.new(lang, script, labels)
|
44
|
-
end
|
45
|
-
|
46
|
-
def googlefonts
|
47
|
-
<<~HEAD.freeze
|
48
|
-
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,600,600i" rel="stylesheet">
|
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=Libre+Baskerville:400,400i,700,700i" rel="stylesheet">
|
51
|
-
HEAD
|
52
|
-
end
|
53
|
-
|
54
|
-
def toclevel
|
55
|
-
<<~HEAD.freeze
|
56
|
-
function toclevel() { var i; var text = "";
|
57
|
-
for(i = 1; i <= #{@htmlToClevels}; i++) {
|
58
|
-
if (i > 1) { text += ","; } text += "h" + i + ":not(:empty):not(.TermNum):not(.AbstractTitle):not(.IntroTitle):not(.ForewordTitle)"; }
|
59
|
-
return text;}
|
60
|
-
HEAD
|
61
|
-
end
|
62
|
-
|
63
|
-
def make_body(xml, docxml)
|
64
|
-
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
|
65
|
-
xml.body **body_attr do |body|
|
66
|
-
make_body1(body, docxml)
|
67
|
-
make_body2(body, docxml)
|
68
|
-
make_body3(body, docxml)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def html_toc(docxml)
|
73
|
-
docxml
|
74
|
-
end
|
75
|
-
|
76
|
-
def make_body3(body, docxml)
|
77
|
-
body.div **{ class: "main-section" } do |div3|
|
78
|
-
foreword docxml, div3
|
79
|
-
abstract docxml, div3
|
80
|
-
keywords docxml, div3
|
81
|
-
boilerplate docxml, div3
|
82
|
-
preface docxml, div3
|
83
|
-
middle docxml, div3
|
84
|
-
footnotes div3
|
85
|
-
comments div3
|
16
|
+
def convert(filename, file = nil, debug = false)
|
17
|
+
file = File.read(filename, encoding: "utf-8") if file.nil?
|
18
|
+
docxml, outname_html, dir = convert_init(file, filename, debug)
|
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
|
86
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"))
|
87
30
|
end
|
88
|
-
|
89
|
-
def authority_cleanup(docxml)
|
90
|
-
dest = docxml.at("//div[@id = 'authority']") || return
|
91
|
-
auth = docxml.at("//div[@class = 'authority']") || return
|
92
|
-
auth.xpath(".//h1 | .//h2").each { |h| h["class"] = "IntroTitle" }
|
93
|
-
dest1 = docxml.xpath("//div[@class = 'authority6']")
|
94
|
-
auth1 = docxml&.at("//div[@id = 'authority6']")&.remove
|
95
|
-
dest1 and auth1 and dest1.each { |d| d.replace(auth1) }
|
96
|
-
dest.replace(auth.remove)
|
97
|
-
a = docxml.at("//div[@id = 'authority1']") and a["class"] = "authority1"
|
98
|
-
a = docxml.at("//div[@id = 'authority2']") and a["class"] = "authority2"
|
99
|
-
a = docxml.at("//div[@id = 'authority3']") and a["class"] = "authority3"
|
100
|
-
a = docxml.at("//div[@id = 'authority3a']") and a["class"] = "authority3"
|
101
|
-
a = docxml.at("//div[@id = 'authority4']") and a["class"] = "authority4"
|
102
|
-
a = docxml.at("//div[@id = 'authority5']") and a["class"] = "authority5"
|
103
|
-
a = docxml.at("//div[@id = 'authority6']") and a["class"] = "authority6"
|
104
|
-
end
|
105
|
-
|
106
|
-
def cleanup(docxml)
|
107
|
-
super
|
108
|
-
term_cleanup(docxml)
|
109
|
-
requirement_cleanup(docxml)
|
110
|
-
end
|
111
|
-
|
112
|
-
def bibliography(isoxml, out)
|
113
|
-
f = isoxml.at(ns("//bibliography/clause | //bibliography/references")) || return
|
114
|
-
page_break(out)
|
115
|
-
isoxml.xpath(ns("//bibliography/clause | //bibliography/references")).each do |f|
|
116
|
-
out.div do |div|
|
117
|
-
div.h1 **{ class: "Section3" } do |h1|
|
118
|
-
if @bibliographycount == 1
|
119
|
-
h1 << "References"
|
120
|
-
else
|
121
|
-
f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
|
122
|
-
end
|
123
|
-
end
|
124
|
-
biblio_list(f, div, false)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def keywords(_docxml, out)
|
130
|
-
kw = @meta.get[:keywords]
|
131
|
-
kw.empty? and return
|
132
|
-
out.div **{ class: "Section3" } do |div|
|
133
|
-
out.div do |div|
|
134
|
-
clause_name(nil, "Keywords", div, class: "IntroTitle")
|
135
|
-
div.p kw.sort.join("; ")
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def termdef_parse(node, out)
|
141
|
-
pref = node.at(ns("./preferred"))
|
142
|
-
out.dl **{ class: "terms_dl" } do |dl|
|
143
|
-
dl.dt do |dt|
|
144
|
-
pref.children.each { |n| parse(n, dt) }
|
145
|
-
end
|
146
|
-
set_termdomain("")
|
147
|
-
dl.dd do |dd|
|
148
|
-
node.children.each { |n| parse(n, dd) unless n.name == "preferred" }
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def term_cleanup(docxml)
|
154
|
-
docxml.xpath("//table[@class = 'terms_dl']").each do |d|
|
155
|
-
prev = d.previous_element
|
156
|
-
next unless prev.name == "table" and prev["class"] == "terms_dl"
|
157
|
-
d.children.each { |n| prev.add_child(n.remove) }
|
158
|
-
d.remove
|
159
|
-
end
|
160
|
-
docxml
|
161
|
-
end
|
162
|
-
|
163
|
-
include BaseConvert
|
164
31
|
end
|
165
32
|
end
|
166
33
|
end
|
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.0.6
|
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-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -257,6 +257,7 @@ files:
|
|
257
257
|
- lib/asciidoctor/nist/reqt.rng
|
258
258
|
- lib/asciidoctor/nist/validate.rb
|
259
259
|
- lib/isodoc/nist/base_convert.rb
|
260
|
+
- lib/isodoc/nist/common.xsl
|
260
261
|
- lib/isodoc/nist/html/_coverpage.scss
|
261
262
|
- lib/isodoc/nist/html/commerce-logo-color.png
|
262
263
|
- lib/isodoc/nist/html/deptofcommerce.png
|
@@ -281,6 +282,8 @@ files:
|
|
281
282
|
- lib/isodoc/nist/i18n-en.yaml
|
282
283
|
- lib/isodoc/nist/metadata.rb
|
283
284
|
- lib/isodoc/nist/metadata_id.rb
|
285
|
+
- lib/isodoc/nist/nist.cswp.xsl
|
286
|
+
- lib/isodoc/nist/nist.sp.xsl
|
284
287
|
- lib/isodoc/nist/pdf_convert.rb
|
285
288
|
- lib/isodoc/nist/refs.rb
|
286
289
|
- lib/isodoc/nist/render.rb
|