metanorma-nist 1.0.8 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +0 -1
  3. data/.github/workflows/ubuntu.yml +10 -7
  4. data/.github/workflows/windows.yml +0 -1
  5. data/README.adoc +22 -0
  6. data/Rakefile +2 -0
  7. data/lib/asciidoctor/nist/biblio.rng +14 -4
  8. data/lib/asciidoctor/nist/cleanup.rb +5 -4
  9. data/lib/asciidoctor/nist/converter.rb +13 -18
  10. data/lib/asciidoctor/nist/front.rb +1 -0
  11. data/lib/asciidoctor/nist/front_id.rb +73 -23
  12. data/lib/asciidoctor/nist/isodoc.rng +444 -1
  13. data/lib/asciidoctor/nist/reqt.rng +23 -0
  14. data/lib/isodoc/nist/base_convert.rb +66 -62
  15. data/lib/isodoc/nist/html/_coverpage.scss +1 -1
  16. data/lib/isodoc/nist/html/html_nist_titlepage.html +1 -1
  17. data/lib/isodoc/nist/html/nist.scss +1 -2
  18. data/lib/isodoc/nist/html/nist_cswp.scss +1 -2
  19. data/lib/isodoc/nist/html/wordstyle.scss +0 -1
  20. data/lib/isodoc/nist/html/wordstyle_cswp.scss +0 -1
  21. data/lib/isodoc/nist/html_convert.rb +30 -68
  22. data/lib/isodoc/nist/metadata.rb +0 -6
  23. data/lib/isodoc/nist/nist.cswp.xsl +1116 -359
  24. data/lib/isodoc/nist/nist.sp.xsl +1276 -512
  25. data/lib/isodoc/nist/pdf_convert.rb +4 -15
  26. data/lib/isodoc/nist/presentation_xml_convert.rb +10 -0
  27. data/lib/isodoc/nist/refs.rb +44 -2
  28. data/lib/isodoc/nist/section.rb +56 -0
  29. data/lib/isodoc/nist/word_convert.rb +2 -42
  30. data/lib/isodoc/nist/word_convert_toc.rb +2 -2
  31. data/lib/isodoc/nist/{xrefs.rb → xref.rb} +2 -2
  32. data/lib/metanorma-nist.rb +2 -0
  33. data/lib/metanorma/nist/processor.rb +6 -8
  34. data/lib/metanorma/nist/version.rb +1 -1
  35. data/metanorma-nist.gemspec +4 -2
  36. metadata +41 -12
@@ -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::PdfConvert
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 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
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
@@ -0,0 +1,10 @@
1
+ require_relative "base_convert"
2
+ require "isodoc"
3
+
4
+ module IsoDoc
5
+ module NIST
6
+ class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
7
+ end
8
+ end
9
+ end
10
+
@@ -21,8 +21,7 @@ module IsoDoc
21
21
  end
22
22
 
23
23
  def reference_format(b, r)
24
- id = bibitem_ref_code(b)
25
- code = render_identifier(id)
24
+ code = render_identifier(bibitem_ref_code(b))
26
25
  if code[0]
27
26
  r << "#{code[0]} "
28
27
  insert_tab(r, 1)
@@ -54,9 +53,52 @@ module IsoDoc
54
53
  end
55
54
 
56
55
  def nist_reference_format(b, r)
56
+ code = render_identifier(bibitem_ref_code(b))
57
+ if code[0]
58
+ r << "#{code[0]} "
59
+ insert_tab(r, 1)
60
+ end
57
61
  bibitem = b.dup.to_xml
58
62
  r.parent.add_child ::Iso690Render.render(bibitem, true)
59
63
  end
64
+
65
+ def bibliography_parse(node, out)
66
+ title = node&.at(ns("./title"))&.text || ""
67
+ out.div do |div|
68
+ unless suppress_biblio_title(node)
69
+ @xrefs.anchor(node['id'], :label, false) and
70
+ clause_parse_title(node, div, node.at(ns("./title")), out) or
71
+ div.h2 title, **{ class: "Section3" }
72
+ end
73
+ biblio_list(node, div, true)
74
+ end
75
+ end
76
+
77
+ def bibliography(isoxml, out)
78
+ f = isoxml.at(ns("//bibliography/clause | //bibliography/references")) || return
79
+ page_break(out)
80
+ isoxml.xpath(ns("//bibliography/clause | //bibliography/references")).each do |f|
81
+ out.div do |div|
82
+ div.h1 **{ class: "Section3" } do |h1|
83
+ if @bibliographycount == 1 then h1 << "References"
84
+ else
85
+ f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
86
+ end
87
+ end
88
+ biblio_list(f, div, false)
89
+ end
90
+ end
91
+ end
92
+
93
+ def suppress_biblio_title(node)
94
+ return false unless node.parent.name == "annex"
95
+ return false if node.parent.xpath("./references | ./clause | "\
96
+ "./terms | ./definitions").size > 1
97
+ title1 = node&.at(ns("./title"))&.text
98
+ return true unless title1
99
+ title2 = node&.parent&.at(ns("./title"))&.text
100
+ title1&.casecmp(title2) == 0
101
+ end
60
102
  end
61
103
  end
62
104
  end
@@ -0,0 +1,56 @@
1
+ module IsoDoc
2
+ module NIST
3
+ module BaseConvert
4
+ def abstract(isoxml, out)
5
+ f = isoxml.at(ns("//preface/abstract")) || return
6
+ #page_break(out)
7
+ out.div **attr_code(id: f["id"]) do |s|
8
+ clause_name(nil, @abstract_lbl, s, class: "AbstractTitle")
9
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
10
+ end
11
+ end
12
+
13
+ # All "[preface]" sections should have class "IntroTitle" to prevent
14
+ # page breaks, but for the Exec Summary
15
+ def preface(isoxml, out)
16
+ isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
17
+ next if skip_render(c, isoxml)
18
+ title = c&.at(ns("./title"))
19
+ patent = ["Call for Patent Claims",
20
+ "Patent Disclosure Notice"].include? title&.text
21
+ preface1(c, title, patent, out)
22
+ end
23
+ end
24
+
25
+ def preface1(c, title, patent, out)
26
+ out.div **attr_code(id: c["id"]) do |s|
27
+ page_break(s) if patent
28
+ clause_name(@xrefs.anchor(c['id'], :label), title, s,
29
+ class: (c.name == "executivesummary") ? "NormalTitle" :
30
+ "IntroTitle")
31
+ c.elements.reject { |c1| c1.name == "title" }.each do |c1|
32
+ parse(c1, s)
33
+ end
34
+ end
35
+ end
36
+
37
+ def middle(isoxml, out)
38
+ clause isoxml, out
39
+ require "byebug"; byebug
40
+ bibliography isoxml, out
41
+ annex isoxml, out
42
+ end
43
+
44
+ def foreword(isoxml, out)
45
+ f = isoxml.at(ns("//foreword")) || return
46
+ out.div **attr_code(id: f["id"]) do |s|
47
+ title = f.at(ns("./title"))
48
+ s.h1(**{ class: "ForewordTitle" }) do |h1|
49
+ title and title.children.each { |e| parse(e, h1) }
50
+ end
51
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -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|
@@ -155,29 +151,6 @@ module IsoDoc
155
151
  docxml
156
152
  end
157
153
 
158
- def bibliography(isoxml, out)
159
- f = isoxml.at(ns("//bibliography/clause | "\
160
- "//bibliography/references")) || return
161
- page_break(out)
162
- isoxml.xpath(ns("//bibliography/clause | "\
163
- "//bibliography/references")).each do |f|
164
- out.div do |div|
165
- #div.p **{ class: "h1Annex" } do |h1|
166
- div.h1 do |h1|
167
- if @bibliographycount == 1
168
- h1 << "References"
169
- else
170
- f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
171
- end
172
- end
173
- f.elements.reject do |e|
174
- ["reference", "title", "bibitem"].include? e.name
175
- end.each { |e| parse(e, div) }
176
- biblio_list(f, div, false)
177
- end
178
- end
179
- end
180
-
181
154
  def keywords(_docxml, out)
182
155
  kw = @meta.get[:keywords]
183
156
  kw.empty? and return
@@ -189,31 +162,18 @@ module IsoDoc
189
162
  end
190
163
 
191
164
  def termdef_parse(node, out)
192
- pref = node.at(ns("./preferred"))
193
165
  out.table **{ class: "terms_dl" } do |dl|
194
166
  dl.tr do |tr|
195
167
  tr.td **{ valign: "top", align: "left" } do |dt|
196
- pref.children.each { |n| parse(n, dt) }
168
+ term_and_termref_parse(node, dt)
197
169
  end
198
- set_termdomain("")
199
170
  tr.td **{ valign: "top" } do |dd|
200
- node.children.each { |n| parse(n, dd) unless n.name == "preferred" }
171
+ term_rest_parse(node, dd)
201
172
  end
202
173
  end
203
174
  end
204
175
  end
205
176
 
206
- def term_cleanup(docxml)
207
- docxml.xpath("//table[@class = 'terms_dl']").each do |d|
208
- prev = d.previous_element
209
- next unless prev and prev.name == "table" and
210
- prev["class"] == "terms_dl"
211
- d.children.each { |n| prev.add_child(n.remove) }
212
- d.remove
213
- end
214
- docxml
215
- end
216
-
217
177
  include BaseConvert
218
178
  end
219
179
  end
@@ -35,7 +35,7 @@ module IsoDoc
35
35
  <span lang="EN-GB"><span
36
36
  style='mso-element:field-begin'></span><span
37
37
  style='mso-spacerun:yes'>&#xA0;</span>TOC
38
- \\h \\z \\t &quot;TableTitle,1&quot; <span
38
+ \\h \\z \\t &quot;TableTitle,tabletitle&quot; <span
39
39
  style='mso-element:field-separator'></span></span>
40
40
  TOC
41
41
 
@@ -43,7 +43,7 @@ module IsoDoc
43
43
  <span lang="EN-GB"><span
44
44
  style='mso-element:field-begin'></span><span
45
45
  style='mso-spacerun:yes'>&#xA0;</span>TOC
46
- \\h \\z \\t &quot;FigureTitle,1&quot; <span
46
+ \\h \\z \\t &quot;FigureTitle,figuretitle&quot; <span
47
47
  style='mso-element:field-separator'></span></span>
48
48
  TOC
49
49
 
@@ -4,7 +4,7 @@ require "fileutils"
4
4
 
5
5
  module IsoDoc
6
6
  module NIST
7
- module BaseConvert
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>#{@annex_lbl} #{num}</b>")
53
+ l10n("<b>#{@labels['annex']} #{num}</b>")
54
54
  end
55
55
 
56
56
  def annex_name(annex, name, div)
@@ -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
@@ -29,18 +29,16 @@ module Metanorma
29
29
  "Metanorma::NIST #{Metanorma::NIST::VERSION}"
30
30
  end
31
31
 
32
- def input_to_isodoc(file, filename)
33
- Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
34
- end
35
-
36
- def output(isodoc_node, outname, format, options={})
32
+ def output(isodoc_node, inname, outname, format, options={})
37
33
  case format
38
34
  when :html
39
- IsoDoc::NIST::HtmlConvert.new(options).convert(outname, isodoc_node)
35
+ IsoDoc::NIST::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
40
36
  when :doc
41
- IsoDoc::NIST::WordConvert.new(options).convert(outname, isodoc_node)
37
+ IsoDoc::NIST::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
42
38
  when :pdf
43
- IsoDoc::NIST::PdfConvert.new(options).convert(outname, isodoc_node)
39
+ IsoDoc::NIST::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
40
+ when :presentation
41
+ IsoDoc::NIST::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
44
42
  else
45
43
  super
46
44
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "1.0.8"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -27,13 +27,15 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "htmlentities", "~> 4.3.4"
28
28
  spec.add_dependency "ruby-jing"
29
29
  spec.add_dependency "twitter_cldr"
30
+ spec.add_dependency "iso-639"
30
31
  spec.add_dependency "tzinfo-data" # we need this for windows only
31
32
 
32
- spec.add_dependency "metanorma-standoc", "~> 1.3.0"
33
- spec.add_dependency "isodoc", "~> 1.0.0"
33
+ spec.add_dependency "metanorma-standoc", "~> 1.4.0"
34
+ spec.add_dependency "isodoc", "~> 1.1.0"
34
35
  #spec.add_dependency "relaton-nist", "~> 0.3.0"
35
36
 
36
37
  spec.add_development_dependency "byebug", "~> 9.1"
38
+ spec.add_development_dependency "sassc", "2.4.0"
37
39
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
38
40
  spec.add_development_dependency "guard", "~> 2.14"
39
41
  spec.add_development_dependency "guard-rspec", "~> 4.7"
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.8
4
+ version: 1.1.2
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-05-26 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: iso-639
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: tzinfo-data
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +86,28 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 1.3.0
89
+ version: 1.4.0
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 1.3.0
96
+ version: 1.4.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: isodoc
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 1.0.0
103
+ version: 1.1.0
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 1.0.0
110
+ version: 1.1.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: byebug
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '9.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sassc
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 2.4.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 2.4.0
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: equivalent-xml
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -284,13 +312,15 @@ files:
284
312
  - lib/isodoc/nist/nist.cswp.xsl
285
313
  - lib/isodoc/nist/nist.sp.xsl
286
314
  - lib/isodoc/nist/pdf_convert.rb
315
+ - lib/isodoc/nist/presentation_xml_convert.rb
287
316
  - lib/isodoc/nist/refs.rb
288
317
  - lib/isodoc/nist/render.rb
289
318
  - lib/isodoc/nist/render_contributors.rb
290
319
  - lib/isodoc/nist/render_dates.rb
320
+ - lib/isodoc/nist/section.rb
291
321
  - lib/isodoc/nist/word_convert.rb
292
322
  - lib/isodoc/nist/word_convert_toc.rb
293
- - lib/isodoc/nist/xrefs.rb
323
+ - lib/isodoc/nist/xref.rb
294
324
  - lib/metanorma-nist.rb
295
325
  - lib/metanorma/nist.rb
296
326
  - lib/metanorma/nist/processor.rb
@@ -300,7 +330,7 @@ homepage: https://github.com/metanorma/metanorma-nist
300
330
  licenses:
301
331
  - BSD-2-Clause
302
332
  metadata: {}
303
- post_install_message:
333
+ post_install_message:
304
334
  rdoc_options: []
305
335
  require_paths:
306
336
  - lib
@@ -315,9 +345,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
345
  - !ruby/object:Gem::Version
316
346
  version: '0'
317
347
  requirements: []
318
- rubyforge_project:
319
- rubygems_version: 2.7.6
320
- signing_key:
348
+ rubygems_version: 3.0.3
349
+ signing_key:
321
350
  specification_version: 4
322
351
  summary: Metanorma NIST gem.
323
352
  test_files: []