metanorma-nist 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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/Rakefile +2 -0
  6. data/lib/asciidoctor/nist/boilerplate.rb +2 -2
  7. data/lib/asciidoctor/nist/cleanup.rb +34 -4
  8. data/lib/asciidoctor/nist/converter.rb +7 -4
  9. data/lib/asciidoctor/nist/front.rb +37 -42
  10. data/lib/asciidoctor/nist/front_id.rb +1 -1
  11. data/lib/asciidoctor/nist/isodoc.rng +12 -6
  12. data/lib/asciidoctor/nist/validate.rb +16 -9
  13. data/lib/isodoc/nist/base_convert.rb +5 -66
  14. data/lib/isodoc/nist/html/_coverpage.css +243 -0
  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/htmlstyle.css +955 -0
  18. data/lib/isodoc/nist/html/nist.css +1055 -0
  19. data/lib/isodoc/nist/html/nist.scss +0 -1
  20. data/lib/isodoc/nist/html/nist_cswp.css +996 -0
  21. data/lib/isodoc/nist/html/nist_cswp.scss +0 -1
  22. data/lib/isodoc/nist/html/wordstyle.css +1440 -0
  23. data/lib/isodoc/nist/html/wordstyle.scss +0 -1
  24. data/lib/isodoc/nist/html/wordstyle_cswp.css +1119 -0
  25. data/lib/isodoc/nist/html/wordstyle_cswp.scss +0 -1
  26. data/lib/isodoc/nist/html_convert.rb +4 -5
  27. data/lib/isodoc/nist/i18n-en.yaml +3 -0
  28. data/lib/isodoc/nist/i18n.rb +10 -0
  29. data/lib/isodoc/nist/init.rb +37 -0
  30. data/lib/isodoc/nist/metadata_id.rb +1 -1
  31. data/lib/isodoc/nist/nist.cswp.xsl +2200 -2318
  32. data/lib/isodoc/nist/nist.sp.xsl +2981 -2886
  33. data/lib/isodoc/nist/pdf_convert.rb +0 -1
  34. data/lib/isodoc/nist/presentation_xml_convert.rb +71 -1
  35. data/lib/isodoc/nist/refs.rb +8 -19
  36. data/lib/isodoc/nist/render.rb +2 -1
  37. data/lib/isodoc/nist/render_dates.rb +0 -25
  38. data/lib/isodoc/nist/section.rb +9 -6
  39. data/lib/isodoc/nist/word_convert.rb +7 -15
  40. data/lib/isodoc/nist/word_convert_toc.rb +2 -2
  41. data/lib/isodoc/nist/xref.rb +1 -24
  42. data/lib/metanorma/nist/processor.rb +0 -4
  43. data/lib/metanorma/nist/version.rb +1 -1
  44. data/metanorma-nist.gemspec +3 -2
  45. metadata +28 -6
@@ -1,5 +1,4 @@
1
1
  require "isodoc"
2
- require_relative "metadata"
3
2
  require "fileutils"
4
3
  require_relative "base_convert"
5
4
 
@@ -1,9 +1,79 @@
1
- require_relative "base_convert"
1
+ require_relative "init"
2
2
  require "isodoc"
3
3
 
4
4
  module IsoDoc
5
5
  module NIST
6
6
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
7
+ def convert1(docxml, filename, dir)
8
+ info docxml, nil
9
+ insert_preface_sections(docxml)
10
+ super
11
+ end
12
+
13
+ def insert_preface_sections(docxml)
14
+ insert_keywords(docxml)
15
+ end
16
+
17
+ def wrap_brackets(txt)
18
+ return txt if /^\[.*\]$/.match txt
19
+ "[#{txt}]"
20
+ end
21
+
22
+ def get_linkend(node)
23
+ contents = non_locality_elems(node).select { |c| !c.text? || /\S/.match(c) }
24
+ return unless contents.empty?
25
+ link = anchor_linkend(node, docid_l10n(node["target"] ||
26
+ wrap_brackets(node['citeas'])))
27
+ link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
28
+ link)
29
+ non_locality_elems(node).each { |n| n.remove }
30
+ node.add_child(link)
31
+ end
32
+
33
+ def annex1(f)
34
+ lbl = @xrefs.anchor(f['id'], :label)
35
+ if t = f.at(ns("./title"))
36
+ t.children = "<strong>#{t.children.to_xml}</strong>"
37
+ end
38
+ prefix_name(f, " &mdash; ", lbl, "title")
39
+ t = f.at(ns("./title"))
40
+ t["xref"] = lbl.gsub(/<[^>]+>/, "")
41
+ end
42
+
43
+ def keyword_clause(kw)
44
+ <<~END
45
+ <clause id="_#{UUIDTools::UUID.random_create}" type="keyword">
46
+ <title>#{@i18n.keywords}</title>
47
+ #{@i18n.keywords_intro}
48
+ <p>#{@i18n.l10n(kw.join("; "))}</p></clause>
49
+ END
50
+ end
51
+
52
+ def insert_keywords(docxml)
53
+ kw = @meta.get[:keywords]
54
+ kw.empty? and return
55
+ if abstract = docxml.at(ns("//preface/abstract"))
56
+ abstract.next = keyword_clause(kw)
57
+ elsif foreword = docxml.at(ns("//preface/foreword"))
58
+ foreword.next = keyword_clause(kw)
59
+ else
60
+ preface_init_insert_pt(docxml)&.children&.first&.
61
+ add_previous_sibling(keyword_clause(kw))
62
+ end
63
+ end
64
+
65
+ def preface_init_insert_pt(docxml)
66
+ docxml.at(ns("//preface")) ||
67
+ docxml.at(ns("//sections")).
68
+ add_previous_sibling("<preface> </preface>").first
69
+ end
70
+
71
+ def clause1(f)
72
+ return if f.name == "references" && suppress_biblio_title(f)
73
+ super
74
+ end
75
+
76
+ include Init
7
77
  end
8
78
  end
9
79
  end
@@ -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)
@@ -35,7 +34,7 @@ module IsoDoc
35
34
  if ftitle = b.at(ns("./formattedref"))
36
35
  ftitle&.children&.each { |n| parse(n, r) }
37
36
  else
38
- title = b.at(ns("./title[@language = '#{@language}']")) || b.at(ns("./title"))
37
+ title = b.at(ns("./title[@language = '#{@lang}']")) || b.at(ns("./title"))
39
38
  r.i do |i|
40
39
  title&.children&.each { |n| parse(n, i) }
41
40
  end
@@ -54,6 +53,11 @@ 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
@@ -62,9 +66,7 @@ module IsoDoc
62
66
  title = node&.at(ns("./title"))&.text || ""
63
67
  out.div do |div|
64
68
  unless suppress_biblio_title(node)
65
- @xrefs.anchor(node['id'], :label, false) and
66
- clause_parse_title(node, div, node.at(ns("./title")), out) or
67
- div.h2 title, **{ class: "Section3" }
69
+ clause_parse_title(node, div, node.at(ns("./title")), out)
68
70
  end
69
71
  biblio_list(node, div, true)
70
72
  end
@@ -76,25 +78,12 @@ module IsoDoc
76
78
  isoxml.xpath(ns("//bibliography/clause | //bibliography/references")).each do |f|
77
79
  out.div do |div|
78
80
  div.h1 **{ class: "Section3" } do |h1|
79
- if @bibliographycount == 1 then h1 << "References"
80
- else
81
81
  f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
82
- end
83
82
  end
84
83
  biblio_list(f, div, false)
85
84
  end
86
85
  end
87
86
  end
88
-
89
- def suppress_biblio_title(node)
90
- return false unless node.parent.name == "annex"
91
- return false if node.parent.xpath("./references | ./clause | "\
92
- "./terms | ./definitions").size > 1
93
- title1 = node&.at(ns("./title"))&.text
94
- return true unless title1
95
- title2 = node&.parent&.at(ns("./title"))&.text
96
- title1&.casecmp(title2) == 0
97
- end
98
87
  end
99
88
  end
100
89
  end
@@ -212,7 +212,8 @@ module Iso690Render
212
212
  container = doc.at("./relation[@type='includedIn']")
213
213
  if container && !date(doc) && date(container&.at("./bibitem"))
214
214
  doc <<
215
- ( container&.at("./bibitem/date[@type = 'issued' or @type = 'published' or @type = 'circulated']")&.remove )
215
+ ( container&.at("./bibitem/date[@type = 'issued' or @type = 'published' or "\
216
+ "@type = 'circulated']")&.remove )
216
217
  end
217
218
  ser = series_title(doc)
218
219
  dr = draft(doc)
@@ -27,31 +27,6 @@ module Iso690Render
27
27
  date.sub(/^(\d\d\d\d).*$/, "\\1")
28
28
  end
29
29
 
30
- =begin
31
- def self.monthyr(isodate)
32
- return nil if isodate.nil?
33
- arr = isodate.split("-")
34
- date = if arr.size == 2
35
- DateTime.new(*arr.map(&:to_i))
36
- else
37
- DateTime.parse(isodate)
38
- end
39
- date.localize(:en).to_additional_s("yMMMM")
40
- end
41
-
42
- def self.mmddyyyy(isodate)
43
- return nil if isodate.nil?
44
- arr = isodate.split("-")
45
- date = if arr.size == 1 and (/^\d+$/.match isodate)
46
- Date.new(*arr.map(&:to_i)).strftime("%Y")
47
- elsif arr.size == 2
48
- Date.new(*arr.map(&:to_i)).strftime("%m-%Y")
49
- else
50
- Date.parse(isodate).strftime("%m-%d-%Y")
51
- end
52
- end
53
- =end
54
-
55
30
  def self.MMMddyyyy(isodate)
56
31
  return nil if isodate.nil?
57
32
  return isodate if isodate == "--"
@@ -3,14 +3,17 @@ module IsoDoc
3
3
  module BaseConvert
4
4
  def abstract(isoxml, out)
5
5
  f = isoxml.at(ns("//preface/abstract")) || return
6
- #page_break(out)
7
6
  out.div **attr_code(id: f["id"]) do |s|
8
- clause_name(nil, @abstract_lbl, s, class: "AbstractTitle")
7
+ clause_name(nil, f.at(ns("./title")) || @i18n.abstract, s,
8
+ class: "AbstractTitle")
9
9
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
10
10
  end
11
11
  end
12
12
 
13
- # All "[preface]" sections should have class "IntroTitle" to prevent
13
+ FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or "\
14
+ "local-name() = 'foreword') or @type = 'keyword']".freeze
15
+
16
+ # All "[preface]" sections should have class "IntroTitle" to prevent
14
17
  # page breaks, but for the Exec Summary
15
18
  def preface(isoxml, out)
16
19
  isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
@@ -25,7 +28,7 @@ module IsoDoc
25
28
  def preface1(c, title, patent, out)
26
29
  out.div **attr_code(id: c["id"]) do |s|
27
30
  page_break(s) if patent
28
- clause_name(@xrefs.anchor(c['id'], :label), title, s,
31
+ clause_name(nil, title, s,
29
32
  class: (c.name == "executivesummary") ? "NormalTitle" :
30
33
  "IntroTitle")
31
34
  c.elements.reject { |c1| c1.name == "title" }.each do |c1|
@@ -34,13 +37,13 @@ module IsoDoc
34
37
  end
35
38
  end
36
39
 
37
- def middle(isoxml, out)
40
+ def middle(isoxml, out)
38
41
  clause isoxml, out
39
42
  bibliography isoxml, out
40
43
  annex isoxml, out
41
44
  end
42
45
 
43
- def foreword(isoxml, out)
46
+ def foreword(isoxml, out)
44
47
  f = isoxml.at(ns("//foreword")) || return
45
48
  out.div **attr_code(id: f["id"]) do |s|
46
49
  title = f.at(ns("./title"))
@@ -1,8 +1,8 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
3
  require "fileutils"
4
- require "sassc"
5
4
  require_relative "base_convert"
5
+ require_relative "init"
6
6
  require_relative "word_convert_toc"
7
7
 
8
8
  module IsoDoc
@@ -64,7 +64,6 @@ module IsoDoc
64
64
  info docxml, div2
65
65
  foreword docxml, div2
66
66
  abstract docxml, div2
67
- keywords docxml, div2
68
67
  boilerplate docxml, div2
69
68
  preface docxml, div2
70
69
  div2.p { |p| p << "&nbsp;" } # placeholder
@@ -73,11 +72,13 @@ module IsoDoc
73
72
  end
74
73
 
75
74
  def authority_cleanup(docxml)
76
- docxml.xpath("//div[@class = 'authority']//h1 | //div[@class = 'authority']//h2").each do |h|
77
- h.name = p
75
+ docxml&.xpath("//div[@class = 'authority']//h1 | "\
76
+ "//div[@class = 'authority']//h2")&.each do |h|
77
+ h.name = "p"
78
78
  h["class"] = "IntroTitle"
79
79
  end
80
- dest1 = docxml.xpath("//div[@class = 'authority6' and not(@id = 'authority6')]")
80
+ dest1 = docxml.xpath("//div[@class = 'authority6' and "\
81
+ "not(@id = 'authority6')]")
81
82
  auth1 = docxml&.at("//div[@id = 'authority6']")&.remove
82
83
  dest1 and auth1 and dest1.each { |d| d.replace(auth1) }
83
84
  insert = docxml.at("//div[@class = 'WordSection2']")
@@ -151,16 +152,6 @@ module IsoDoc
151
152
  docxml
152
153
  end
153
154
 
154
- def keywords(_docxml, out)
155
- kw = @meta.get[:keywords]
156
- kw.empty? and return
157
- #out.div **{ class: "Section3" } do |div|
158
- out.div do |div|
159
- clause_name(nil, "Keywords", div, class: "IntroTitle")
160
- div.p kw.sort.join("; ")
161
- end
162
- end
163
-
164
155
  def termdef_parse(node, out)
165
156
  out.table **{ class: "terms_dl" } do |dl|
166
157
  dl.tr do |tr|
@@ -175,6 +166,7 @@ module IsoDoc
175
166
  end
176
167
 
177
168
  include BaseConvert
169
+ include Init
178
170
  end
179
171
  end
180
172
  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
 
@@ -50,35 +50,12 @@ module IsoDoc
50
50
  end
51
51
 
52
52
  def annex_name_lbl(clause, num)
53
- l10n("<b>#{@labels['annex']} #{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)} &mdash; "
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
53
+ l10n("<strong>#{@labels['annex']} #{num}</strong>")
67
54
  end
68
55
 
69
56
  def hiersep
70
57
  "-"
71
58
  end
72
-
73
- def terms_parse(node, out)
74
- out.div **attr_code(id: node["id"]) do |div|
75
- node.at(ns("./title")) and
76
- clause_parse_title(node, div, node.at(ns("./title")), out)
77
- node.elements.each do |e|
78
- parse(e, div) unless %w{title source}.include? e.name
79
- end
80
- end
81
- end
82
59
  end
83
60
  end
84
61
  end
@@ -29,10 +29,6 @@ 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
32
  def output(isodoc_node, inname, outname, format, options={})
37
33
  case format
38
34
  when :html
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -30,11 +30,12 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "iso-639"
31
31
  spec.add_dependency "tzinfo-data" # we need this for windows only
32
32
 
33
- spec.add_dependency "metanorma-standoc", "~> 1.4.0"
34
- spec.add_dependency "isodoc", "~> 1.1.0"
33
+ spec.add_dependency "metanorma-standoc", "~> 1.5.0"
34
+ spec.add_dependency "isodoc", "~> 1.2.0"
35
35
  #spec.add_dependency "relaton-nist", "~> 0.3.0"
36
36
 
37
37
  spec.add_development_dependency "byebug", "~> 9.1"
38
+ spec.add_development_dependency "sassc", "2.4.0"
38
39
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
39
40
  spec.add_development_dependency "guard", "~> 2.14"
40
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.1.0
4
+ version: 1.2.1
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-06-26 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.4.0
89
+ version: 1.5.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.4.0
96
+ version: 1.5.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: 1.1.0
103
+ version: 1.2.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.1.0
110
+ version: 1.2.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: byebug
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
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
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: equivalent-xml
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -272,6 +286,7 @@ files:
272
286
  - lib/asciidoctor/nist/validate.rb
273
287
  - lib/isodoc/nist/base_convert.rb
274
288
  - lib/isodoc/nist/common.xsl
289
+ - lib/isodoc/nist/html/_coverpage.css
275
290
  - lib/isodoc/nist/html/_coverpage.scss
276
291
  - lib/isodoc/nist/html/commerce-logo-color.png
277
292
  - lib/isodoc/nist/html/deptofcommerce.png
@@ -279,20 +294,27 @@ files:
279
294
  - lib/isodoc/nist/html/header_cswp.html
280
295
  - lib/isodoc/nist/html/html_nist_intro.html
281
296
  - lib/isodoc/nist/html/html_nist_titlepage.html
297
+ - lib/isodoc/nist/html/htmlstyle.css
282
298
  - lib/isodoc/nist/html/htmlstyle.scss
283
299
  - lib/isodoc/nist/html/logo.png
284
300
  - lib/isodoc/nist/html/logo_cswp.png
301
+ - lib/isodoc/nist/html/nist.css
285
302
  - lib/isodoc/nist/html/nist.scss
303
+ - lib/isodoc/nist/html/nist_cswp.css
286
304
  - lib/isodoc/nist/html/nist_cswp.scss
287
305
  - lib/isodoc/nist/html/scripts.html
288
306
  - lib/isodoc/nist/html/word_nist_intro.html
289
307
  - lib/isodoc/nist/html/word_nist_intro_cswp.html
290
308
  - lib/isodoc/nist/html/word_nist_titlepage.html
291
309
  - lib/isodoc/nist/html/word_nist_titlepage_cswp.html
310
+ - lib/isodoc/nist/html/wordstyle.css
292
311
  - lib/isodoc/nist/html/wordstyle.scss
312
+ - lib/isodoc/nist/html/wordstyle_cswp.css
293
313
  - lib/isodoc/nist/html/wordstyle_cswp.scss
294
314
  - lib/isodoc/nist/html_convert.rb
295
315
  - lib/isodoc/nist/i18n-en.yaml
316
+ - lib/isodoc/nist/i18n.rb
317
+ - lib/isodoc/nist/init.rb
296
318
  - lib/isodoc/nist/metadata.rb
297
319
  - lib/isodoc/nist/metadata_id.rb
298
320
  - lib/isodoc/nist/nist.cswp.xsl