metanorma-nist 1.1.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +14 -0
  3. data/Rakefile +2 -0
  4. data/lib/asciidoctor/nist/boilerplate.rb +2 -2
  5. data/lib/asciidoctor/nist/cleanup.rb +34 -4
  6. data/lib/asciidoctor/nist/converter.rb +20 -6
  7. data/lib/asciidoctor/nist/front.rb +37 -46
  8. data/lib/asciidoctor/nist/front_id.rb +1 -1
  9. data/lib/asciidoctor/nist/isodoc.rng +16 -7
  10. data/lib/asciidoctor/nist/nist.rng +18 -0
  11. data/lib/asciidoctor/nist/validate.rb +16 -9
  12. data/lib/isodoc/nist/base_convert.rb +26 -75
  13. data/lib/isodoc/nist/html/_coverpage.css +243 -0
  14. data/lib/isodoc/nist/html/htmlstyle.css +955 -0
  15. data/lib/isodoc/nist/html/nist.css +1055 -0
  16. data/lib/isodoc/nist/html/nist.scss +6 -7
  17. data/lib/isodoc/nist/html/nist_cswp.css +996 -0
  18. data/lib/isodoc/nist/html/nist_cswp.scss +6 -7
  19. data/lib/isodoc/nist/html/wordstyle.css +1520 -0
  20. data/lib/isodoc/nist/html/wordstyle.scss +74 -4
  21. data/lib/isodoc/nist/html/wordstyle_cswp.css +1194 -0
  22. data/lib/isodoc/nist/html/wordstyle_cswp.scss +68 -3
  23. data/lib/isodoc/nist/html_convert.rb +3 -0
  24. data/lib/isodoc/nist/i18n-en.yaml +3 -0
  25. data/lib/isodoc/nist/i18n.rb +10 -0
  26. data/lib/isodoc/nist/init.rb +37 -0
  27. data/lib/isodoc/nist/metadata_id.rb +1 -1
  28. data/lib/isodoc/nist/nist.cswp.xsl +2264 -2323
  29. data/lib/isodoc/nist/nist.sp.xsl +2697 -2542
  30. data/lib/isodoc/nist/pdf_convert.rb +0 -1
  31. data/lib/isodoc/nist/presentation_xml_convert.rb +71 -1
  32. data/lib/isodoc/nist/refs.rb +2 -17
  33. data/lib/isodoc/nist/render.rb +2 -1
  34. data/lib/isodoc/nist/render_dates.rb +0 -25
  35. data/lib/isodoc/nist/section.rb +26 -13
  36. data/lib/isodoc/nist/word_convert.rb +47 -14
  37. data/lib/isodoc/nist/xref.rb +1 -24
  38. data/lib/metanorma/nist/version.rb +1 -1
  39. data/metanorma-nist.gemspec +3 -2
  40. metadata +28 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fd53abb651e6ed6f607f8cd697e00819b5db05c5e4540df273348c2bc61a85f
4
- data.tar.gz: c76ec958d5ebae5b2fb3f9b24db5186645022e48745fcf3f4382c93d2634a046
3
+ metadata.gz: 567105c7de8ee67a8864ef8f5001ef078ad65580a15c7766ac32faa65aa192a3
4
+ data.tar.gz: 12507bb0dad9555461ca6ed5fa9943c6d4c14e9f2505cbff626aeec6c18825d3
5
5
  SHA512:
6
- metadata.gz: a96a9016064a2ab39601cb0d500e77625d550f1175c84a1bcc4f4858d2a46c3661507797ed627e059500242a9a7fd78dc37f3f74592eee9ea66dad0e5e70257d
7
- data.tar.gz: 61ea2bf1cb04e1840010e0f7af70b08987fd7d957584ed44862d3eaf1adc74d7bb9f6d0f0bab83635c0b63825d1f3580201c0981e0462bc7ce82a96fb1dd3069
6
+ metadata.gz: 75df1bf28376729c76247c9a23132fc58aa369f32cceff62a54951dd80a4ffddb96766be7b6187f2085767fd444859af98e628cf77e8c69ccf21aacd6ba88016
7
+ data.tar.gz: 3ef6cac86084b8c56c2b634fb3064408465c5e311331f812446a688c78557512fc1cc4f67c0dfdf0d0087e49413584c7bf4d850eb0fae96936550fc856d9255c
@@ -659,6 +659,20 @@ Errata tables must have a header row containing the headings _Date, Type, Change
659
659
  |===
660
660
  ----
661
661
 
662
+ === Lists
663
+
664
+ If an ordered list is intended to describe “steps” within a process, it should start with Arabic numbers and should be encoded with the class `steps`:
665
+
666
+ Encoding an ordered list as steps:
667
+
668
+ [source, asciidoctor]
669
+ ----
670
+ [class=steps]
671
+ . First Step
672
+ . Second Step
673
+ . Third Step
674
+ ----
675
+
662
676
  === Glosaries
663
677
 
664
678
  Glossaries are given as definition lists with role attribute `[.glossary]`:
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require 'isodoc/gem_tasks'
3
4
 
5
+ IsoDoc::GemTasks.install
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
8
  task default: :spec
@@ -94,8 +94,8 @@ module Asciidoctor
94
94
 
95
95
  def boilerplate_isodoc(xmldoc)
96
96
  conv = super
97
- conv.labels = conv.labels.merge({nist_division: @nistdivision,
98
- nist_division_address: @nistdivisionaddress})
97
+ conv.i18n.set(:nist_division, @nistdivision)
98
+ conv.i18n.set(:nist_division_address, @nistdivisionaddress)
99
99
  conv
100
100
  end
101
101
 
@@ -3,9 +3,15 @@ module Asciidoctor
3
3
  class Converter < Standoc::Converter
4
4
  def cleanup(xmldoc)
5
5
  sourcecode_cleanup(xmldoc)
6
+ annex_rename(xmldoc)
6
7
  super
7
8
  end
8
9
 
10
+ def annex_rename(xmldoc)
11
+ return unless xmldoc.xpath("//references").size == 1
12
+ replace_title(xmldoc, "//annex[references]", @i18n&.normref, true)
13
+ end
14
+
9
15
  def sourcecode_cleanup(xmldoc)
10
16
  xmldoc.xpath("//sourcecode").each do |x|
11
17
  x.traverse do |n|
@@ -37,7 +43,7 @@ module Asciidoctor
37
43
  move_execsummary_into_preface(x, preface)
38
44
  end
39
45
 
40
- def move_clauses_into_preface1(x, preface)
46
+ def move_clauses_into_preface1(x, preface)
41
47
  x.xpath("//clause[@preface]").each do |c|
42
48
  c.delete("preface")
43
49
  title = c&.at("./title")&.text.downcase
@@ -45,9 +51,9 @@ module Asciidoctor
45
51
  c.name = "executivesummary" if title == "executive summary"
46
52
  preface.add_child c.remove
47
53
  end
48
- end
54
+ end
49
55
 
50
- def move_execsummary_into_preface(x, preface)
56
+ def move_execsummary_into_preface(x, preface)
51
57
  x.xpath("//clause[@executivesummary]").each do |c|
52
58
  c.delete("executivesummary")
53
59
  title = c&.at("./title")&.text.downcase
@@ -150,7 +156,7 @@ module Asciidoctor
150
156
  elsif metaid = bib&.at("./docidentifier[@type = 'NIST']")&.text
151
157
  key = metaid.sub(/-(\d+)/) {|m| sprintf "-%09d", ($1.to_i) }
152
158
  elsif metaid = bib&.at("./docidentifier[not(@type = 'DOI' or "\
153
- "@type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")&.text
159
+ "@type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")&.text
154
160
  key = metaid.sub(/-(\d+)/) {|m| sprintf "-%09d", ($1.to_i) }
155
161
  else # no usable docid
156
162
  key = "000000000" + bib["id"]
@@ -171,6 +177,30 @@ module Asciidoctor
171
177
  end
172
178
  acc
173
179
  end
180
+
181
+ def section_names_refs_cleanup(x)
182
+ replace_title(x, "//bibliography//references[@normative = 'true']",
183
+ @i18n&.normref, true)
184
+ replace_title(x, "//bibliography//references[@normative = 'false']",
185
+ @i18n&.bibliography, true)
186
+ end
187
+
188
+ def section_names_terms_cleanup(x)
189
+ replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
190
+ replace_title(x, "//definitions[@type = 'abbreviated_terms']", @i18n&.abbrev)
191
+ replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
192
+ replace_title(x, "//sections//terms#{SYMnoABBR} | //sections//clause[.//terms]#{SYMnoABBR}",
193
+ @i18n&.termsdefsymbols, true)
194
+ replace_title(x, "//sections//terms#{ABBRnoSYM} | //sections//clause[.//terms]#{ABBRnoSYM}",
195
+ @i18n&.termsdefabbrev, true)
196
+ replace_title(x, "//sections//terms#{SYMABBR} | //sections//clause[.//terms]#{SYMABBR}",
197
+ @i18n&.termsdefsymbolsabbrev, true)
198
+ replace_title(x, "//sections//terms#{NO_SYMABBR} | //sections//clause[.//terms]#{NO_SYMABBR}",
199
+ @i18n&.termsdefsymbolsabbrev, true)
200
+ replace_title(
201
+ x, "//sections//terms[not(.//definitions)] | //sections//clause[.//terms][not(.//definitions)]",
202
+ @i18n&.termsdef, true)
203
+ end
174
204
  end
175
205
  end
176
206
  end
@@ -61,6 +61,15 @@ module Asciidoctor
61
61
  super
62
62
  end
63
63
 
64
+ def olist(node)
65
+ id = Asciidoctor::Standoc::Utils::anchor_or_uuid(node)
66
+ noko do |xml|
67
+ xml.ol **attr_code(id: id, class: node.attr("class")) do |xml_ol|
68
+ node.items.each { |item| li(xml_ol, item) }
69
+ end
70
+ end.join("\n")
71
+ end
72
+
64
73
  def glossary(node)
65
74
  noko do |xml|
66
75
  xml.dl **{id: Asciidoctor::Standoc::Utils::anchor_or_uuid(node),
@@ -79,8 +88,8 @@ module Asciidoctor
79
88
  end
80
89
 
81
90
  def doctype(node)
82
- d = node.attr("doctype")
83
- d = "standard" if d == "article" # article is Asciidoctor default
91
+ d = super || "standard"
92
+ d = "standard" if d == "article" # article is Asciidoctor default
84
93
  d
85
94
  end
86
95
 
@@ -100,9 +109,12 @@ module Asciidoctor
100
109
  def outputs(node, ret)
101
110
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
102
111
  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")
112
+ html_converter(node).convert(@filename + ".presentation.xml",
113
+ nil, false, "#{@filename}.html")
114
+ doc_converter(node).convert(@filename + ".presentation.xml",
115
+ nil, false, "#{@filename}.doc")
116
+ pdf_converter(node)&.convert(@filename + ".presentation.xml",
117
+ nil, false, "#{@filename}.pdf")
106
118
  end
107
119
 
108
120
  def clause_parse(attrs, xml, node)
@@ -137,6 +149,8 @@ module Asciidoctor
137
149
  case ret
138
150
  when "glossary", "terminology"
139
151
  "terms and definitions"
152
+ when "introduction"
153
+ "donotrecognise_introduction"
140
154
  else
141
155
  super
142
156
  end
@@ -159,7 +173,7 @@ module Asciidoctor
159
173
  def bibliography_annex_parse(attrs, xml, node)
160
174
  attrs1 = attrs.merge(id: "_" + UUIDTools::UUID.random_create)
161
175
  xml.annex **attr_code(attrs1) do |xml_section|
162
- xml_section.title { |t| t << "Bibliography" }
176
+ xml_section.title { |t| t << node.title }
163
177
  @biblio = true
164
178
  xml.references **attr_code(attrs.merge(normative: true)) do |r|
165
179
  r << node.content
@@ -5,14 +5,7 @@ require_relative "./front_id.rb"
5
5
 
6
6
  module Asciidoctor
7
7
  module NIST
8
- # A {Converter} implementation that generates RSD output, and a document
9
- # schema encapsulation of the document for validation
10
-
11
8
  class Converter < Standoc::Converter
12
- def doctype(node)
13
- node.attr("doctype") || "sp-800"
14
- end
15
-
16
9
  def datetypes
17
10
  super + %w(abandoned superseded)
18
11
  end
@@ -27,31 +20,35 @@ module Asciidoctor
27
20
  end
28
21
  end
29
22
 
23
+ def asciidoc_sub(text)
24
+ Asciidoctor::Standoc::Utils::asciidoc_sub(text)
25
+ end
26
+
30
27
  def title_subtitle(node, t, at)
31
28
  return unless node.attr("title-sub")
32
29
  t.title(**attr_code(at.merge(type: "subtitle"))) do |t1|
33
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
30
+ t1 << asciidoc_sub(node.attr("title-sub"))
34
31
  end
35
32
  node.attr("title-sub-short") and
36
33
  t.title(**attr_code(at.merge(type: "short-subtitle"))) do |t1|
37
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub-short"))
34
+ t1 << asciidoc_sub(node.attr("title-sub-short"))
38
35
  end
39
36
  end
40
37
 
41
38
  def title_document_class(node, t, at)
42
39
  return unless node.attr("title-document-class")
43
40
  t.title(**attr_code(at.merge(type: "document-class"))) do |t1|
44
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-document-class"))
41
+ t1 << asciidoc_sub(node.attr("title-document-class"))
45
42
  end
46
43
  end
47
44
 
48
45
  def title_main(node, t, at)
49
46
  t.title(**attr_code(at.merge(type: "main"))) do |t1|
50
- t1 << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main")) || node.title)
47
+ t1 << (asciidoc_sub(node.attr("title-main")) || node.title)
51
48
  end
52
49
  node.attr("title-main-short") and
53
50
  t.title(**attr_code(at.merge(type: "short-title"))) do |t1|
54
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main-short"))
51
+ t1 << asciidoc_sub(node.attr("title-main-short"))
55
52
  end
56
53
  end
57
54
 
@@ -68,12 +65,21 @@ module Asciidoctor
68
65
  personal_author(node, xml)
69
66
  end
70
67
 
68
+ def default_publisher
69
+ "National Institute of Standards and Technology"
70
+ end
71
+
71
72
  def metadata_publisher(node, xml)
72
- xml.contributor do |c|
73
- c.role **{ type: "publisher" }
74
- c.organization do |a|
75
- a.name "NIST"
76
- d = node.attr("nist-division") and a.subdivision d
73
+ publishers = node.attr("publisher") || default_publisher
74
+ csv_split(publishers)&.each do |p|
75
+ xml.contributor do |c|
76
+ c.role **{ type: "publisher" }
77
+ c.organization do |a|
78
+ a.name p
79
+ if p == default_publisher
80
+ d = node.attr("nist-division") and a.subdivision d
81
+ end
82
+ end
77
83
  end
78
84
  end
79
85
  end
@@ -86,9 +92,10 @@ module Asciidoctor
86
92
  node.attr("technical-committee") and
87
93
  a.committee(node.attr("technical-committee"))
88
94
  node.attr("subcommittee") and
89
- a.subcommittee(node.attr("subcommittee"),
90
- **attr_code(type: node.attr("subcommittee-type"),
91
- number: node.attr("subcommittee-number")))
95
+ a.subcommittee(
96
+ node.attr("subcommittee"),
97
+ **attr_code(type: node.attr("subcommittee-type"),
98
+ number: node.attr("subcommittee-number")))
92
99
  (node.attr("workgroup") || node.attr("workinggroup")) and
93
100
  a.workgroup(node.attr("workgroup") || node.attr("workinggroup"),
94
101
  **attr_code(type: node.attr("workgroup-type"),
@@ -105,19 +112,6 @@ module Asciidoctor
105
112
  end
106
113
  end
107
114
 
108
- def metadata_copyright(node, xml)
109
- from = node.attr("copyright-year") || node.attr("copyrightyear") ||
110
- Date.today.year
111
- xml.copyright do |c|
112
- c.from from
113
- c.owner do |owner|
114
- owner.organization do |o|
115
- o.name "NIST"
116
- end
117
- end
118
- end
119
- end
120
-
121
115
  def metadata_source(node, xml)
122
116
  super
123
117
  node.attr("doc-email") && xml.uri(node.attr("doc-email"), type: "email")
@@ -149,14 +143,13 @@ module Asciidoctor
149
143
  end
150
144
 
151
145
  def relaton_relation_descriptions
152
- super.merge({
153
- "supersedes" => "obsoletes",
154
- "superseded-by" => "obsoleted-by",
155
- })
146
+ super.merge({ "supersedes" => "obsoletes",
147
+ "superseded-by" => "obsoleted-by", })
156
148
  end
157
149
 
158
150
  def metadata_getrelation(node, xml, type, desc = nil)
159
- if type == "obsoleted-by" and desc.nil? and node.attr("superseding-status")
151
+ if type == "obsoleted-by" and desc.nil? and
152
+ node.attr("superseding-status")
160
153
  metadata_superseding_doc(node, xml)
161
154
  end
162
155
  super
@@ -166,10 +159,8 @@ module Asciidoctor
166
159
  xml.relation **{ type: "obsoletedBy" } do |r|
167
160
  r.bibitem **{ type: "standard" } do |b|
168
161
  metadata_superseding_titles(b, node)
169
- doi = node.attr("superseding-doi") and
170
- b.uri doi, **{ type: "doi" }
171
- url = node.attr("superseding-url") and
172
- b.uri url, **{ type: "uri" }
162
+ doi = node.attr("superseding-doi") and b.uri doi, **{ type: "doi" }
163
+ url = node.attr("superseding-url") and b.uri url, **{ type: "uri" }
173
164
  metadata_superseding_ids(b, xml)
174
165
  metadata_superseding_authors(b, node)
175
166
  metadata_superseding_dates(b, node)
@@ -205,19 +196,19 @@ module Asciidoctor
205
196
  def metadata_superseding_titles(b, node)
206
197
  if node.attr("superseding-title")
207
198
  b.title **{ type: "main" } do |t|
208
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-title"))
199
+ t << asciidoc_sub(node.attr("superseding-title"))
209
200
  end
210
201
  node.attr("superseding-subtitle") and
211
202
  b.title **{ type: "subtitle" } do |t|
212
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-subtitle"))
203
+ t << asciidoc_sub(node.attr("superseding-subtitle"))
213
204
  end
214
205
  else
215
206
  b.title **{ type: "main" } do |t|
216
- t << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main")) || node.title)
207
+ t << (asciidoc_sub(node.attr("title-main")) || node.title)
217
208
  end
218
209
  node.attr("title-sub") and
219
210
  b.title **{ type: "subtitle" } do |t|
220
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
211
+ t << asciidoc_sub(node.attr("title-sub"))
221
212
  end
222
213
  end
223
214
  end
@@ -64,7 +64,7 @@ module Asciidoctor
64
64
  end
65
65
 
66
66
  def status_abbr(stage, iter)
67
- IsoDoc::NIST::Metadata.new(nil, nil, {}).status_abbr(stage, iter)
67
+ IsoDoc::NIST::Metadata.new(nil, nil, @i18n).status_abbr(stage, iter)
68
68
  end
69
69
 
70
70
  def add_id_parts(args, long)
@@ -42,8 +42,11 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
+ <!-- attribute target { xsd:IDREF }, -->
45
46
  <attribute name="target">
46
- <data type="IDREF"/>
47
+ <data type="string">
48
+ <param name="pattern">\i\c*|\c+#\c+</param>
49
+ </data>
47
50
  </attribute>
48
51
  <optional>
49
52
  <attribute name="type">
@@ -922,6 +925,9 @@
922
925
  <optional>
923
926
  <attribute name="script"/>
924
927
  </optional>
928
+ <optional>
929
+ <attribute name="type"/>
930
+ </optional>
925
931
  <optional>
926
932
  <attribute name="obligation">
927
933
  <choice>
@@ -961,9 +967,6 @@
961
967
  </define>
962
968
  <define name="content-subsection">
963
969
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
970
  <ref name="Content-Section"/>
968
971
  </element>
969
972
  </define>
@@ -992,6 +995,9 @@
992
995
  </choice>
993
996
  </attribute>
994
997
  </optional>
998
+ <optional>
999
+ <attribute name="type"/>
1000
+ </optional>
995
1001
  <optional>
996
1002
  <ref name="section-title"/>
997
1003
  </optional>
@@ -1011,9 +1017,6 @@
1011
1017
  </define>
1012
1018
  <define name="clause">
1013
1019
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1020
  <ref name="Clause-Section"/>
1018
1021
  </element>
1019
1022
  </define>
@@ -1042,6 +1045,9 @@
1042
1045
  </choice>
1043
1046
  </attribute>
1044
1047
  </optional>
1048
+ <optional>
1049
+ <attribute name="type"/>
1050
+ </optional>
1045
1051
  <optional>
1046
1052
  <ref name="section-title"/>
1047
1053
  </optional>
@@ -1180,6 +1186,9 @@
1180
1186
  <optional>
1181
1187
  <attribute name="script"/>
1182
1188
  </optional>
1189
+ <optional>
1190
+ <attribute name="type"/>
1191
+ </optional>
1183
1192
  <optional>
1184
1193
  <attribute name="obligation">
1185
1194
  <choice>
@@ -9,6 +9,24 @@
9
9
  <start>
10
10
  <ref name="nist-standard"/>
11
11
  </start>
12
+ <define name="ol">
13
+ <element name="ol">
14
+ <attribute name="id">
15
+ <data type="ID"/>
16
+ </attribute>
17
+ <optional>
18
+ <attribute name="class">
19
+ <value>steps</value>
20
+ </attribute>
21
+ </optional>
22
+ <oneOrMore>
23
+ <ref name="li"/>
24
+ </oneOrMore>
25
+ <zeroOrMore>
26
+ <ref name="note"/>
27
+ </zeroOrMore>
28
+ </element>
29
+ </define>
12
30
  <define name="DocumentType">
13
31
  <value>standard</value>
14
32
  </define>