metanorma-nist 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30193344892f68ba4a979316250fe4e6268cdbbe1ae476b48169f34d5ebcfcf6
4
- data.tar.gz: 5a2165e97b94d197e9e5247b7fdb21bdc33c38041da812824f5298452f6a0512
3
+ metadata.gz: ed6d6518c86f59d927b205f623877b3e860e6874d561e1748b53142ee6d26d25
4
+ data.tar.gz: 881aa89fd9aeceea3216f116fb5465fd2082bd636f77d6f4dbf6b15ef08a7ba6
5
5
  SHA512:
6
- metadata.gz: 1fb5c7754d436c24af54b760c3cbb9b8561ada612d8aa022c709b651eb8bf8f16fc43d4f2fc7efb65de9743c0167a85f86fc58816f9b3b8b250da380e4f98fd4
7
- data.tar.gz: d0ed65e3f7cb8cf0abd6e9235522faaf2e4fc14d2d0d77b8b51a678719d081caa02403de3b9b7b37f52e1f33f1395440006fe14b33278900bf8311f2e1d0079d
6
+ metadata.gz: b468ba8980ad51e00d0ffddc0d09b3440fe6d1d2d381df330f2807cfdb476d460469a62fb36be75e0b031950a99394f0458236d442030540c5787bfcb51cde4d
7
+ data.tar.gz: '0012912ef3a4dc926c45432ab69c30af5dd771b3042ca86e30615d892ca1eb1281d06dff0dc8372697e3a9b8e2f164ec3b2cbcf7447a1b8191e36a30632bfa23'
data/.travis.yml CHANGED
@@ -8,9 +8,9 @@ rvm:
8
8
  - ruby-head
9
9
  before_install:
10
10
  - gem install bundler -v 2.0.1
11
- - npm install -g puppeteer
12
- - npm install
13
- - unset _JAVA_OPTIONS
11
+ - travis_retry sudo apt-get update
12
+ - curl -L https://raw.githubusercontent.com/metanorma/metanorma-linux-setup/master/ubuntu-install-puppeteer.sh | bash
14
13
  matrix:
15
14
  allow_failures:
16
15
  - rvm: ruby-head
16
+
data/README.adoc CHANGED
@@ -1,8 +1,9 @@
1
1
  = metanorma-nist: Metanorma processor for the NIST SP 800 document classes
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-nist.svg["Gem Version", link="https://rubygems.org/gems/metanorma-nist"]
4
- image:https://img.shields.io/travis/riboseinc/metanorma-nist/master.svg["Build Status", link="https://travis-ci.com/riboseinc/metanorma-nist"]
5
- image:https://codeclimate.com/github/riboseinc/metanorma-nist/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/metanorma-nist"]
4
+ image:https://img.shields.io/travis/metanorma/metanorma-nist/master.svg["Build Status", link="https://travis-ci.com/metanorma/metanorma-nist"]
5
+ image:https://ci.appveyor.com/api/projects/status/c5e8e3qtn689a5h0?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/metanorma-nist"]
6
+ image:https://codeclimate.com/github/metanorma/metanorma-nist/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-nist"]
6
7
 
7
8
  WARNING: This gem is still under development.
8
9
 
@@ -30,7 +31,7 @@ as end deliverable NIST documents.
30
31
 
31
32
  == Structure
32
33
 
33
- This gem inherits from the https://github.com/riboseinc/metanorma-standoc
34
+ This gem inherits from the https://github.com/metanorma/metanorma-standoc
34
35
  gem, and aligns closely to it.
35
36
 
36
37
 
@@ -38,13 +39,13 @@ gem, and aligns closely to it.
38
39
 
39
40
  Please see https://www.metanorma.com for instructions to get started.
40
41
 
41
- If you are using a Mac, the https://github.com/riboseinc/metanorma-macos-setup
42
+ If you are using a Mac, the https://github.com/metanorma/metanorma-macos-setup
42
43
  repository has instructions on setting up your machine to run Metanorma
43
44
  scripts such as this one. You need only run the following in a Terminal console:
44
45
 
45
46
  [source,console]
46
47
  ----
47
- $ bash <(curl -s https://raw.githubusercontent.com/riboseinc/metanorma-macos-setup/master/metanorma-setup)
48
+ $ bash <(curl -s https://raw.githubusercontent.com/metanorma/metanorma-macos-setup/master/metanorma-setup)
48
49
  $ gem install metanorma-cli
49
50
  $ gem install metanorma-nist
50
51
  ----
@@ -70,26 +71,16 @@ Please refer to the Metanorma-ISO documentation for general documentation.
70
71
 
71
72
  * Metanorma-ISO guidance: https://www.metanorma.com/software/metanorma-iso/docs/guidance/
72
73
 
73
-
74
- ////
75
- ** http://asciimath.org[AsciiMathML] is used for mathematical formatting.
76
- The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
77
- which is syntactically stricter than the common MathJax processor;
78
- if you do not get expected results, try bracketing terms your in AsciiMathML
79
- expressions.
80
- ////
81
-
82
-
83
74
  == Approach
84
75
 
85
76
  === Document model
86
77
 
87
78
  The NIST SP 800 document model is detailed here:
88
79
 
89
- * https://github.com/riboseinc/metanorma-model-nist[NIST SP 800 document model]
80
+ * https://github.com/metanorma/metanorma-model-nist[NIST SP 800 document model]
90
81
 
91
82
  It is an instance of the
92
- https://github.com/riboseinc/metanorma-model-standoc[StandardDocument model].
83
+ https://github.com/metanorma/metanorma-model-standoc[StandardDocument model].
93
84
 
94
85
 
95
86
  === Document input
@@ -117,7 +108,7 @@ NOTE: The Asciidoctor gem is used for AsciiDoc input parsing.
117
108
 
118
109
  Metadata of the document is provided through AsciiDoc document attributes.
119
110
 
120
- https://github.com/riboseinc/metanorma-standoc[Metanorma-Standoc]
111
+ https://github.com/metanorma/metanorma-standoc[Metanorma-Standoc]
121
112
  documents all common Metanorma document attributes.
122
113
 
123
114
  Where these preexisting metanorma attributes correspond to attributes already used
@@ -133,9 +124,11 @@ The attributes relevant to NIST documents include:
133
124
  `:copyright-year:`:: The year which will be claimed as when the copyright for
134
125
  the document was issued.
135
126
 
136
- `:title:`:: The main component of the English title of the document
137
- (mandatory). (The first line of the AsciiDoc document, which contains the title
138
- introduced with `=`, is ignored)
127
+ `:title-main:`:: The main component of the title of the document
128
+ (mandatory). If absent, the first line of the AsciiDoc document, which contains the title
129
+ introduced with `=`, is used.
130
+
131
+ `:title-sub:`:: The subtitle of the document.
139
132
 
140
133
  `:technical-committee:`:: The name of the relevant committee producing the document (mandatory).
141
134
 
@@ -143,11 +136,28 @@ introduced with `=`, is ignored)
143
136
 
144
137
  `:uri:`:: The URI to which this standard is published.
145
138
 
146
- `:docnumber:`:: The internal identifier referring to this document.
139
+ `:docnumber:`:: The internal identifier referring to this document. The identifier is a number;
140
+ the prefix, e.g. "NIST SP", is supplied by the `:series:` attribute. The NIST identifier is
141
+ docnumber-edition (if edition is present)
142
+
143
+ `:docidentifier:`:: The document identifier for the document. Normally this should not be supplied,
144
+ as the document identifier is composed from the document series, document number,
145
+ and edition/revision. If the `:docidentifier:` value is provided, it will override this composed
146
+ value.
147
147
 
148
148
  `:edition:`:: Edition (revision) of the document. The value of
149
149
  this attribute will be displayed as part of the heading, prefixed with "Revision".
150
150
 
151
+ `:status:`:: Document status/stage. The permitted types are:
152
+ +
153
+ --
154
+ * `internal-draft`
155
+ * `public-draft`
156
+ * `final`
157
+ * `retired-draft`
158
+ * `withdrawn`
159
+ --
160
+
151
161
  ////
152
162
 
153
163
  `:doctype:`:: The document type (mandatory). The permitted types are:
@@ -173,14 +183,6 @@ this attribute will be displayed as part of the heading, prefixed with "Revision
173
183
  `administrative`::: Internal administrative documents
174
184
  --
175
185
 
176
- `:status:`:: Document status/stage. The permitted types are:
177
- +
178
- `rfc`::: OGC RFC (proposal)
179
- `candidate`::: Candidate Standard
180
- `published`::: Published
181
- `deprecated`::: Deprecated
182
- `retired`::: Retired
183
-
184
186
  `:committee:`:: The name of the relevant committee producing the document (mandatory). The legal values are:
185
187
  `technical`, `planning`, `strategic-member-advisory`
186
188
  `:subcommittee:`:: The name of the relevant subcommittee producing the document
@@ -203,6 +205,9 @@ The following document attributes are specific to this document class:
203
205
 
204
206
  `:doc-email:`:: Email contact for document
205
207
 
208
+ `:doi:`:: DOI URL for document (distinct from `:uri:`, which is the URL that NIST
209
+ publishes the document under.)
210
+
206
211
  `:call-for-patent-claims:`:: Include the Call for Patent Claims in document drafts,
207
212
  and the Patent Disclosure Notice in finalised documents.
208
213
 
@@ -212,9 +217,59 @@ notice and commitment to license have been received.
212
217
  `:patent-contact:`:: Contact for the Call for Patent Claims or Patent Disclosure Notice.
213
218
  If not supplied, `:doc-email:` is used.
214
219
 
220
+ `:iteration:`:: The iteration of a stage, in case there have been multiple drafts.
221
+ Can be a number, or text (e.g. "initial", "final").
222
+
223
+ `:series:`:: The publication series that the document belongs to. Legal values are:
224
+ +
225
+ --
226
+ * nist-ams
227
+ * building-science
228
+ * nist-fips
229
+ * nist-gcr
230
+ * nist-hb
231
+ * itl-bulletin
232
+ * jpcrd
233
+ * nist-jres
234
+ * letter-circular
235
+ * nist-monograph
236
+ * nist-ncstar
237
+ * nist-nsrds
238
+ * nistir
239
+ * product-stadnards
240
+ * nist-sp
241
+ * nist-tn
242
+ * other
243
+ * csrc-white-paper
244
+ * csrc-book
245
+ * csrc-use-case
246
+ * csrc-building-block
247
+ --
248
+
249
+ `:subseries:`:: The secondary publication series that the document belongs to. Legal values are:
250
+ +
251
+ --
252
+ * computer-security (for NIST SP)
253
+ * information-security (for NIST SP)
254
+ --
255
+
256
+ `:comment-from:`:: The beginning of the period during which comments may be submitted to the NIST
257
+ document draft. ISO-8601 date.
258
+
259
+ `:comment-to:`:: The end of the period during which comments may be submitted to the NIST document
260
+ draft. The end of the period may change, and may be left open-ended (omitted). ISO-8601 date.
261
+
262
+ `:comment-extended:`:: The date on which the during which comments may be submitted to the NIST document
263
+ draft was extended.
264
+
265
+ `:biblio-as-appendix:`:: By default, bibliographies are treated as separate from appendixes in output:
266
+ they are published in front of any appendixes. This is the prescribed behaviour for NIST documents moving
267
+ forward. If present, bibliographies are treated in the legacy manner: they are treated like appendixes,
268
+ and are given an appendix number according to where in the document they occur.
269
+
215
270
  == Asciidoctor features specific to NIST
216
271
 
217
- The https://github.com/riboseinc/metanorma-standoc[metanorma-standoc]
272
+ The https://github.com/metanorma/metanorma-standoc[metanorma-standoc]
218
273
  gem documents the customisations of Asciidoctor markup common to all metanorma gems.
219
274
  The following markup is specific to this gem:
220
275
 
@@ -222,6 +277,7 @@ The following markup is specific to this gem:
222
277
 
223
278
  The following sections are automatically moved to the document preface.
224
279
 
280
+ * Foreword
225
281
  * Abstract
226
282
  * Keywords (drawn from document attribute, see above)
227
283
 
@@ -253,9 +309,26 @@ the document is in draft (has a `:draft:` attribute).
253
309
 
254
310
  ==== Abstract
255
311
 
256
- As with all metanorma gems, Abstracts are recognised as any clause with the style attribute
312
+ As with all Metanorma gems, Abstracts are recognised as any clause with the style attribute
257
313
  `[abstract]`. They are rendered in the document preface, under the Metanorma XML tag `abstract`.
258
314
 
315
+ ==== Foreword
316
+
317
+ As with all Metanorma gems, the foreword is considered to be any text before the first
318
+ section title. The foreword is used to capture the introductory statement on the publication
319
+ series that precedes the abstract, and its title is entered as a caption:
320
+
321
+ [source,asciidoctor]
322
+ ----
323
+ = Document
324
+ :title-main: NIST Report
325
+ :title-sub: Subtitle of Report
326
+
327
+ .Reports on Computer Systems Technology
328
+ The Information Technology Laboratory (ITL) at the National Institute
329
+ of Standards and Technology (NIST) promotes the U.S. economy and public welfare...
330
+ ----
331
+
259
332
  === Executive Summary
260
333
 
261
334
  This is any section that appears in the preface with the title Executive Summary.
@@ -263,10 +336,9 @@ It is rendered after all other preface sections.
263
336
 
264
337
  === Terms and definitions
265
338
 
266
- NIST documents do not provide for an extensive Terms & Definitions structure, as seen
267
- in ISO and ISO-derived standards. Instead, they use acronyms and glossary appendixes.
268
- These should be given as simple definition lists, without extensive embedded notes, examples,
269
- or sources.
339
+ Glossaries in NIST documents correspond to Terms & Definitions sections elsewhere in
340
+ Metanorma. They are appendices in NIST, and any appendix in NIST Metanorma with the
341
+ title "Glossary" or "Terminology" is treated as a Terms & Definitions section.
270
342
 
271
343
  === Pseudocode
272
344
 
data/appveyor.yml ADDED
@@ -0,0 +1,30 @@
1
+ version: '{build}'
2
+
3
+ environment:
4
+ matrix:
5
+ - RUBY_VERSION: 25
6
+ - RUBY_VERSION: 24
7
+ - RUBY_VERSION: 23
8
+ - RUBY_VERSION: _trunk
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - RUBY_VERSION: _trunk
13
+
14
+ install:
15
+ - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
16
+ - refreshenv
17
+
18
+ build_script:
19
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
20
+ - bundle update
21
+ - bundle install
22
+
23
+ before_test:
24
+ - ruby -v
25
+ - gem -v
26
+ - bundle -v
27
+
28
+ test_script:
29
+ - bundle exec rake
30
+
@@ -156,9 +156,9 @@
156
156
  <zeroOrMore>
157
157
  <ref name="contact"/>
158
158
  </zeroOrMore>
159
- <optional>
159
+ <zeroOrMore>
160
160
  <ref name="uri"/>
161
- </optional>
161
+ </zeroOrMore>
162
162
  </element>
163
163
  </define>
164
164
  <define name="fullname">
@@ -246,9 +246,9 @@
246
246
  <optional>
247
247
  <ref name="abbreviation"/>
248
248
  </optional>
249
- <optional>
249
+ <zeroOrMore>
250
250
  <ref name="uri"/>
251
- </optional>
251
+ </zeroOrMore>
252
252
  <zeroOrMore>
253
253
  <ref name="org-identifier"/>
254
254
  </zeroOrMore>
@@ -469,12 +469,13 @@
469
469
  <value>film</value>
470
470
  <value>video</value>
471
471
  <value>broadcast</value>
472
- <value>graphic work</value>
472
+ <value>graphic_work</value>
473
473
  <value>music</value>
474
474
  <value>patent</value>
475
475
  <value>inbook</value>
476
476
  <value>incollection</value>
477
477
  <value>inproceedings</value>
478
+ <value>journal</value>
478
479
  </choice>
479
480
  </define>
480
481
  <define name="BibliographicItem">
@@ -739,39 +740,44 @@
739
740
  <element name="series">
740
741
  <optional>
741
742
  <attribute name="type">
742
- <choice>
743
- <value>main</value>
744
- <value>alt</value>
745
- </choice>
743
+ <ref name="SeriesType"/>
746
744
  </attribute>
747
745
  </optional>
748
746
  <choice>
749
- <ref name="btitle"/>
750
747
  <ref name="formattedref"/>
748
+ <group>
749
+ <ref name="btitle"/>
750
+ <optional>
751
+ <ref name="bplace"/>
752
+ </optional>
753
+ <optional>
754
+ <ref name="seriesorganization"/>
755
+ </optional>
756
+ <optional>
757
+ <ref name="abbreviation"/>
758
+ </optional>
759
+ <optional>
760
+ <ref name="seriesfrom"/>
761
+ </optional>
762
+ <optional>
763
+ <ref name="seriesto"/>
764
+ </optional>
765
+ <optional>
766
+ <ref name="seriesnumber"/>
767
+ </optional>
768
+ <optional>
769
+ <ref name="seriespartnumber"/>
770
+ </optional>
771
+ </group>
751
772
  </choice>
752
- <optional>
753
- <ref name="bplace"/>
754
- </optional>
755
- <optional>
756
- <ref name="seriesorganization"/>
757
- </optional>
758
- <optional>
759
- <ref name="abbreviation"/>
760
- </optional>
761
- <optional>
762
- <ref name="seriesfrom"/>
763
- </optional>
764
- <optional>
765
- <ref name="seriesto"/>
766
- </optional>
767
- <optional>
768
- <ref name="seriesnumber"/>
769
- </optional>
770
- <optional>
771
- <ref name="seriespartnumber"/>
772
- </optional>
773
773
  </element>
774
774
  </define>
775
+ <define name="SeriesType">
776
+ <choice>
777
+ <value>main</value>
778
+ <value>alt</value>
779
+ </choice>
780
+ </define>
775
781
  <define name="seriesorganization">
776
782
  <element name="organization">
777
783
  <text/>
@@ -849,6 +855,7 @@
849
855
  <value>includes</value>
850
856
  <value>instance</value>
851
857
  <value>partOf</value>
858
+ <value>hasDraft</value>
852
859
  </choice>
853
860
  </attribute>
854
861
  <element name="bibitem">
@@ -861,9 +868,6 @@
861
868
  </define>
862
869
  <define name="version">
863
870
  <element name="version">
864
- <optional>
865
- <ref name="vedition"/>
866
- </optional>
867
871
  <optional>
868
872
  <ref name="revision-date"/>
869
873
  </optional>
@@ -18,9 +18,6 @@ module Asciidoctor
18
18
 
19
19
  def example(node)
20
20
  return pseudocode_example(node) if node.attr("style") == "pseudocode"
21
- return recommendation(node) if node.attr("style") == "recommendation"
22
- return requirement(node) if node.attr("style") == "requirement"
23
- return permission(node) if node.attr("style") == "permission"
24
21
  super
25
22
  end
26
23
 
@@ -34,30 +31,6 @@ module Asciidoctor
34
31
  end.join("\n")
35
32
  end
36
33
 
37
- def recommendation(node)
38
- noko do |xml|
39
- xml.recommendation **id_attr(node) do |ex|
40
- wrap_in_para(node, ex)
41
- end
42
- end.join("\n")
43
- end
44
-
45
- def requirement(node)
46
- noko do |xml|
47
- xml.requirement **id_attr(node) do |ex|
48
- wrap_in_para(node, ex)
49
- end
50
- end.join("\n")
51
- end
52
-
53
- def permission(node)
54
- noko do |xml|
55
- xml.permission **id_attr(node) do |ex|
56
- wrap_in_para(node, ex)
57
- end
58
- end.join("\n")
59
- end
60
-
61
34
  def table(node)
62
35
  return errata(node) if node.attr("style") == "errata"
63
36
  super
@@ -132,6 +105,15 @@ module Asciidoctor
132
105
  end
133
106
  end
134
107
 
108
+ # skip annex/terms/terms, which is empty node
109
+ def termdef_subclause_cleanup(xmldoc)
110
+ xmldoc.xpath("//terms[terms]").each do |t|
111
+ next if t.parent.name == "terms"
112
+ t.children.each { |n| n.parent = t.parent }
113
+ t.remove
114
+ end
115
+ end
116
+
135
117
  def makexml(node)
136
118
  result = ["<?xml version='1.0' encoding='UTF-8'?>\n<nist-standard>"]
137
119
  @draft = node.attributes.has_key?("draft")
@@ -140,7 +122,7 @@ module Asciidoctor
140
122
  result << "</nist-standard>"
141
123
  result = textcleanup(result)
142
124
  ret1 = cleanup(Nokogiri::XML(result))
143
- validate(ret1)
125
+ validate(ret1) unless @novalid
144
126
  ret1.root.add_namespace(nil, EXAMPLE_NAMESPACE)
145
127
  ret1
146
128
  end
@@ -160,6 +142,7 @@ module Asciidoctor
160
142
  @callforpatentclaims = node.attr("call-for-patent-claims")
161
143
  @commitmenttolicence = node.attr("commitment-to-licence")
162
144
  @patentcontact = node.attr("patent-contact")
145
+ @biblioasappendix = node.attr("biblio-as-appendix")
163
146
  super
164
147
  end
165
148
 
@@ -201,8 +184,9 @@ module Asciidoctor
201
184
  preface.add_child introduction.remove if introduction
202
185
  x.xpath("//clause[@preface]").each do |c|
203
186
  c.delete("preface")
204
- c.name = "reviewernote" if c&.at("./title")&.text.downcase == "note to reviewers"
205
- c.name = "executivesummary" if c&.at("./title")&.text.downcase == "executive summary"
187
+ title = c&.at("./title")&.text.downcase
188
+ c.name = "reviewernote" if title == "note to reviewers"
189
+ c.name = "executivesummary" if title == "executive summary"
206
190
  preface.add_child c.remove
207
191
  end
208
192
  callforpatentclaims(x, preface)
@@ -218,7 +202,7 @@ module Asciidoctor
218
202
 
219
203
  <li><p>assurance that a license to such essential patent claim(s) will be made available to applicants desiring to utilize the license for the purpose of complying with the guidance or requirements in this ITL draft publication either:</p>
220
204
 
221
- <ol><li><p>under reasonable terms and conditions that are demonstrably free of any unfair discrimination; or</p></li>
205
+ <ol><li><p>under reasonable terms and conditions that are demonstrably free of any unfair discrimination; or</p></li>
222
206
 
223
207
  <li><p>without compensation and under reasonable terms and conditions that are demonstrably free of any unfair discrimination.</p></li></ol>
224
208
  </li></ol>
@@ -253,8 +237,8 @@ module Asciidoctor
253
237
  if @callforpatentclaims
254
238
  docemail = x&.at("//uri[@type = 'email']")&.text || "???"
255
239
  docnumber = x&.at("//docnumber")&.text || "???"
256
- status = x&.at("//bibdata/status")&.text
257
- published = status.nil? || status == "published"
240
+ status = x&.at("//bibdata/status/stage")&.text
241
+ published = status.nil? || status == "final"
258
242
  preface.add_child patent_text(published, docemail, docnumber)
259
243
  end
260
244
  end
@@ -311,8 +295,17 @@ module Asciidoctor
311
295
  noko do |xml|
312
296
  case sectiontype(node)
313
297
  when "normative references" then norm_ref_parse(a, xml, node)
298
+ when "glossary", "terminology"
299
+ if node.attr("style") == "appendix" && node.level == 1
300
+ @term_def = true
301
+ terms_annex_parse(a, xml, node)
302
+ @term_def = false
303
+ else
304
+ clause_parse(a, xml, node)
305
+ end
314
306
  else
315
- if @term_def then term_def_subclause_parse(a, xml, node)
307
+ if @term_def
308
+ term_def_subclause_parse(a, xml, node)
316
309
  elsif @biblio then bibliography_parse(a, xml, node)
317
310
  elsif node.attr("style") == "bibliography"
318
311
  bibliography_parse(a, xml, node)
@@ -327,15 +320,56 @@ module Asciidoctor
327
320
  end.join("\n")
328
321
  end
329
322
 
323
+ def bibliography_parse(a, xml, node)
324
+ @biblioasappendix and node.level == 1 and
325
+ return bibliography_annex_parse(a, xml, node)
326
+ super
327
+ end
328
+
329
+ def bibliography_annex_parse(attrs, xml, node)
330
+ attrs1 = attrs.merge(id: "_" + UUIDTools::UUID.random_create)
331
+ xml.annex **attr_code(attrs1) do |xml_section|
332
+ xml_section.title { |t| t << "Bibliography" }
333
+ @biblio = true
334
+ xml.references **attr_code(attrs) do |xml_section|
335
+ xml_section << node.content
336
+ end
337
+ end
338
+ @biblio = false
339
+ end
340
+
341
+ def terms_annex_parse(attrs, xml, node)
342
+ attrs1 = attrs.merge(id: "_" + UUIDTools::UUID.random_create)
343
+ xml.annex **attr_code(attrs1) do |xml_section|
344
+ xml_section.title { |name| name << node.title }
345
+ xml_section.terms **attr_code(attrs) do |terms|
346
+ (s = node.attr("source")) && s.split(/,/).each do |s1|
347
+ terms.termdocsource(nil, **attr_code(bibitemid: s1))
348
+ end
349
+ terms << node.content
350
+ end
351
+ end
352
+ end
353
+
354
+ SECTIONS_TO_VALIDATE = "//references[not(parent::clause)]/title | "\
355
+ "//clause[descendant::references][not(parent::clause)]/title".freeze
356
+
330
357
  def section_validate(doc)
331
358
  super
332
- f = doc.xpath("//references[not(parent::clause)]/title | //clause[descendant::references][not(parent::clause)]/title")
359
+ f = doc.xpath(SECTIONS_TO_VALIDATE)
333
360
  names = f.map { |s| s&.text }
334
361
  return if names.empty?
335
362
  return if names == ["References"]
336
363
  return if names == ["Bibliography"]
337
364
  return if names == ["References", "Bibliography"]
338
- warn "Reference clauses #{names.join(', ')} do not follow expected pattern in NIST"
365
+ warn "Reference clauses #{names.join(', ')} do not follow expected "\
366
+ "pattern in NIST"
367
+ end
368
+
369
+ def sections_order_cleanup(x)
370
+ s = x.at("//sections")
371
+ make_preface(x, s)
372
+ x.xpath("//sections/annex").reverse_each { |r| s.next = r.remove }
339
373
  end
340
374
 
341
375
  def html_converter(node)