metanorma-nist 0.1.1 → 0.1.2

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: 75fb9c059ae72c09ccc3d401bb440d5763ec93d1dcb4cba42e93e7f981fd79a4
4
- data.tar.gz: 067a9a1a8ea310fc7948c3423bbd693fd5a5e63ff03b7dab5fe50dcd605f2150
3
+ metadata.gz: 06e9acdd4c6462c4631f0a098a7751a03d1bb9ba277966b09c83210b1575ff01
4
+ data.tar.gz: 8f0b1995cc43710b39feda4d04ebf5f4a2f5e53309095bb6705df1a40de56d09
5
5
  SHA512:
6
- metadata.gz: 678c8b927d107d784d1fddaabeb650f0e03b74b558e1ef4c75f8f959a94d96f00414ea76d4db8666f3ff502ffdfa349db9ca728fffa01a01d78a5a21ea86a8c2
7
- data.tar.gz: 26f7b3f77ea5226a601b4dee47d4c7c6b62d3967e0840c713b0e2521d6cfc5da37b30b3398bf51001b403302cdb94acb5381c6f7140f9b57f5dda53ff7e6cc2e
6
+ metadata.gz: bd0d74a632520a62213e4ab8137baeb8c19237563d198b7313f891519bfb3eee0cd5dd2f122f1cfbb6f2918c0ec20bbbe623b99e11f2070332084f65d3d73e1e
7
+ data.tar.gz: 6f0705059fe77b479e54f180c63d576db9c229f6ab6a466a36ee6b42431a5b8e2edd56bc8395d00532afc02b8ed631cc8c9ee49a21239f9ad1215408e3f79ed2
@@ -146,7 +146,8 @@ module Asciidoctor
146
146
 
147
147
  def clause_parse(attrs, xml, node)
148
148
  attrs[:preface] = true if node.attr("style") == "preface"
149
- attrs[:executivesummary] = true if node.attr("style") == "executive-summary"
149
+ attrs[:executivesummary] = true if node.attr("style") ==
150
+ "executive-summary"
150
151
  super
151
152
  end
152
153
 
@@ -233,6 +234,19 @@ module Asciidoctor
233
234
  end
234
235
  end
235
236
 
237
+ NIST_PREFIX_REFS = "SP|FIPS"
238
+
239
+ def refitem(xml, item, node)
240
+ item.sub!(Regexp.new("^(<ref[^>]+>)\\[(#{NIST_PREFIX_REFS}) "),
241
+ "\\1[NIST \\2 ")
242
+ super
243
+ end
244
+
245
+ def fetch_ref(xml, code, year, **opts)
246
+ code.sub!(Regexp.new("^(#{NIST_PREFIX_REFS}) "), "NIST \\1 ")
247
+ super
248
+ end
249
+
236
250
  def html_converter(node)
237
251
  IsoDoc::NIST::HtmlConvert.new(html_extract_attributes(node))
238
252
  end
@@ -345,7 +345,17 @@ module IsoDoc
345
345
  end
346
346
 
347
347
  def reference_format(b, r)
348
- if ftitle = b.at(ns("./formattedref"))
348
+ code = iso_bibitem_ref_code(b)
349
+ if /^\[\d+\]$/.match(code)
350
+ r << "#{code} "
351
+ insert_tab(r, 1)
352
+ end
353
+ reference_format1(b, r)
354
+ r << " [#{code}] " unless /^\[\d+\]$/.match(code)
355
+ end
356
+
357
+ def reference_format1(b, r)
358
+ if ftitle = b.at(ns("./formattedref"))
349
359
  ftitle&.children&.each { |n| parse(n, r) }
350
360
  else
351
361
  title = b.at(ns("./title[@language = '#{@language}']")) || b.at(ns("./title"))
@@ -353,7 +363,6 @@ module IsoDoc
353
363
  title&.children&.each { |n| parse(n, i) }
354
364
  end
355
365
  end
356
- r << "[#{iso_bibitem_ref_code(b)}] "
357
366
  end
358
367
 
359
368
  def omit_docid_prefix(prefix)
@@ -234,7 +234,7 @@ table {
234
234
  list-style: none;
235
235
  }
236
236
 
237
- #toc li {
237
+ #toc li a {
238
238
  padding: 5px 10px;
239
239
  font-size: 14px;
240
240
  }
@@ -246,6 +246,7 @@ table {
246
246
  }
247
247
 
248
248
  #toc a:hover {
249
+ box-shadow: none;
249
250
  color: white;
250
251
  }
251
252
 
@@ -1012,9 +1013,11 @@ h2 p {
1012
1013
  margin-bottom: 150px;
1013
1014
  }
1014
1015
 
1016
+ /*
1015
1017
  .coverpage-title .title-second {
1016
1018
  display: none;
1017
1019
  }
1020
+ */
1018
1021
 
1019
1022
  .coverpage-stage-block {
1020
1023
  font-family: 'Source Sans Pro', sans-serif;
@@ -66,6 +66,7 @@ $('#toggle').on('click', function(){
66
66
  !function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(this,function(){"use strict";return function(A){function e(A){A.icon=A.hasOwnProperty("icon")?A.icon:"",A.visible=A.hasOwnProperty("visible")?A.visible:"hover",A.placement=A.hasOwnProperty("placement")?A.placement:"right",A.ariaLabel=A.hasOwnProperty("ariaLabel")?A.ariaLabel:"Anchor",A.class=A.hasOwnProperty("class")?A.class:"",A.truncate=A.hasOwnProperty("truncate")?Math.floor(A.truncate):64}function t(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new Error("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}function i(){if(null===document.head.querySelector("style.anchorjs")){var A,e=document.createElement("style");e.className="anchorjs",e.appendChild(document.createTextNode("")),void 0===(A=document.head.querySelector('[rel="stylesheet"], style'))?document.head.appendChild(e):document.head.insertBefore(e,A),e.sheet.insertRule(" .anchorjs-link { opacity: 0; text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }",e.sheet.cssRules.length),e.sheet.insertRule(" *:hover > .anchorjs-link, .anchorjs-link:focus { opacity: 1; }",e.sheet.cssRules.length),e.sheet.insertRule(" [data-anchorjs-icon]::after { content: attr(data-anchorjs-icon); }",e.sheet.cssRules.length),e.sheet.insertRule(' @font-face { font-family: "anchorjs-icons"; src: url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAA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AAAAAAAAAAABAAH//wAP) format("truetype"); }',e.sheet.cssRules.length)}}this.options=A||{},this.elements=[],e(this.options),this.isTouchDevice=function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)},this.add=function(A){var n,o,s,a,r,c,h,l,u,d,f,p=[];if(e(this.options),"touch"===(f=this.options.visible)&&(f=this.isTouchDevice()?"always":"hover"),A||(A="h2, h3, h4, h5, h6"),0===(n=t(A)).length)return this;for(i(),o=document.querySelectorAll("[id]"),s=[].map.call(o,function(A){return A.id}),r=0;r<n.length;r++)if(this.hasAnchorJSLink(n[r]))p.push(r);else{if(n[r].hasAttribute("id"))a=n[r].getAttribute("id");else if(n[r].hasAttribute("data-anchor-id"))a=n[r].getAttribute("data-anchor-id");else{u=l=this.urlify(n[r].textContent),h=0;do{void 0!==c&&(u=l+"-"+h),c=s.indexOf(u),h+=1}while(-1!==c);c=void 0,s.push(u),n[r].setAttribute("id",u),a=u}a.replace(/-/g," "),(d=document.createElement("a")).className="anchorjs-link "+this.options.class,d.href="#"+a,d.setAttribute("aria-label",this.options.ariaLabel),d.setAttribute("data-anchorjs-icon",this.options.icon),"always"===f&&(d.style.opacity="1"),""===this.options.icon&&(d.style.font="1em/1 anchorjs-icons","left"===this.options.placement&&(d.style.lineHeight="inherit")),"left"===this.options.placement?(d.style.position="absolute",d.style.marginLeft="-1em",d.style.paddingRight="0.5em",n[r].insertBefore(d,n[r].firstChild)):(d.style.paddingLeft="0.375em",n[r].appendChild(d))}for(r=0;r<p.length;r++)n.splice(p[r]-r,1);return this.elements=this.elements.concat(n),this},this.remove=function(A){for(var e,i,n=t(A),o=0;o<n.length;o++)(i=n[o].querySelector(".anchorjs-link"))&&(-1!==(e=this.elements.indexOf(n[o]))&&this.elements.splice(e,1),n[o].removeChild(i));return this},this.removeAll=function(){this.remove(this.elements)},this.urlify=function(A){var t=/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g;return this.options.truncate||e(this.options),A.trim().replace(/\'/gi,"").replace(t,"-").replace(/-{2,}/g,"-").substring(0,this.options.truncate).replace(/^-+|-+$/gm,"").toLowerCase()},this.hasAnchorJSLink=function(A){var e=A.firstChild&&(" "+A.firstChild.className+" ").indexOf(" anchorjs-link ")>-1,t=A.lastChild&&(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ")>-1;return e||t||!1}}}); </script>
67
67
 
68
68
  <script>
69
+ /*
69
70
  $(document).ready(function() {
70
71
  $('[id^=toc]').each(function ()
71
72
  {
@@ -74,6 +75,7 @@ $('#toggle').on('click', function(){
74
75
  currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
75
76
  });
76
77
  });
78
+ */
77
79
  anchors.options = {
78
80
  placement: 'left'
79
81
  };
@@ -58,6 +58,7 @@ $('#toggle').on('click', function(){
58
58
  </script>
59
59
 
60
60
  <script>
61
+ /*
61
62
  $(document).ready(function() {
62
63
  $('[id^=toc]').each(function ()
63
64
  {
@@ -66,5 +67,6 @@ $('#toggle').on('click', function(){
66
67
  currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
67
68
  });
68
69
  });
70
+ */
69
71
  </script>
70
72
 
@@ -12,12 +12,14 @@ module Iso690Render
12
12
  parse(docxml.root, embedded)
13
13
  end
14
14
 
15
+ =begin
15
16
  def self.multiplenames_and(names)
16
17
  return "" if names.length == 0
17
18
  return names[0] if names.length == 1
18
19
  return "#{names[0]} and #{names[1]}" if names.length == 2
19
20
  names[0..-2].join(", ") + " and #{names[-1]}"
20
21
  end
22
+ =end
21
23
 
22
24
  def self.multiplenames(names)
23
25
  names.join(", ")
@@ -33,7 +35,7 @@ module Iso690Render
33
35
  elsif initials.empty?
34
36
  given.map{ |m| m.text[0] }.join("")
35
37
  else
36
- initials.map{ |m| m.text }.join("")
38
+ initials.map{ |m| m.text[0] }.join("")
37
39
  end
38
40
  end
39
41
 
@@ -66,7 +68,7 @@ module Iso690Render
66
68
 
67
69
  def self.contributorRole(contributors)
68
70
  return "" unless contributors.length > 0
69
- if contributors[0]["role"] == "editor"
71
+ if contributors[0]&.at("role/@type")&.text == "editor"
70
72
  return contributors.length > 1 ? " (Eds.)" : "(Ed.)"
71
73
  end
72
74
  ""
@@ -97,17 +99,20 @@ module Iso690Render
97
99
  doc&.at("./medium")&.text
98
100
  end
99
101
 
102
+ =begin
100
103
  def self.edition(doc)
101
104
  x = doc.at("./edition")
102
105
  return "" unless x
103
106
  return x.text unless /^\d+$/.match x.text
104
107
  x.text.to_i.localize.to_rbnf_s("SpelloutRules", "spellout-ordinal")
105
108
  end
109
+ =end
106
110
 
107
111
  def self.is_nist(doc)
108
112
  publisher = doc&.at("./contributor[role/@type = 'publisher']/organization/name")&.text
109
113
  abbr = doc&.at("./contributor[role/@type = 'publisher']/organization/abbreviation")&.text
110
- publisher == "NIST" || abbr == "NIST"
114
+ publisher == "NIST" || abbr == "NIST" ||
115
+ publisher == "National Institute of Standards and Technology"
111
116
  end
112
117
 
113
118
  def self.placepub(doc)
@@ -132,7 +137,7 @@ module Iso690Render
132
137
  from = date&.at("./from")&.text
133
138
  to = date&.at("./to")&.text
134
139
  return MMMddyyyy(on) if on
135
- return "#{MMMddyyyy(from)}&ndash;#{MMMMddyyyy(to)}" if from
140
+ return "#{MMMddyyyy(from)}&ndash;#{MMMddyyyy(to)}" if from
136
141
  nil
137
142
  end
138
143
 
@@ -142,7 +147,7 @@ module Iso690Render
142
147
  if pub
143
148
  ret = pub
144
149
  ret += " (updated #{updated})" if updated
145
- return pub
150
+ return ret
146
151
  end
147
152
  pub = date1(doc&.at("./date[@type = 'circulated']")) and
148
153
  return pub
@@ -254,6 +259,7 @@ module Iso690Render
254
259
  ret.join(", ")
255
260
  end
256
261
 
262
+ =begin
257
263
  def self.monthyr(isodate)
258
264
  return nil if isodate.nil?
259
265
  arr = isodate.split("-")
@@ -268,21 +274,26 @@ module Iso690Render
268
274
  def self.mmddyyyy(isodate)
269
275
  return nil if isodate.nil?
270
276
  arr = isodate.split("-")
271
- date = if arr.size == 2
277
+ date = if arr.size == 1 and (/^\d+$/.match isodate)
278
+ Date.new(*arr.map(&:to_i)).strftime("%Y")
279
+ elsif arr.size == 2
272
280
  Date.new(*arr.map(&:to_i)).strftime("%m-%Y")
273
281
  else
274
282
  Date.parse(isodate).strftime("%m-%d-%Y")
275
283
  end
276
284
  end
285
+ =end
277
286
 
278
287
  def self.MMMddyyyy(isodate)
279
288
  return nil if isodate.nil?
280
289
  arr = isodate.split("-")
281
- date = if arr.size == 2
282
- Date.new(*arr.map(&:to_i)).strftime("%B, %Y")
283
- else
284
- Date.parse(isodate).strftime("%B %d, %Y")
285
- end
290
+ date = if arr.size == 1 and (/^\d+$/.match isodate)
291
+ Date.new(*arr.map(&:to_i)).strftime("%Y")
292
+ elsif arr.size == 2
293
+ Date.new(*arr.map(&:to_i)).strftime("%B %Y")
294
+ else
295
+ Date.parse(isodate).strftime("%B %d, %Y")
296
+ end
286
297
  end
287
298
 
288
299
  def self.draft(doc)
@@ -319,11 +330,14 @@ module Iso690Render
319
330
 
320
331
  def self.parse(doc, embedded = false)
321
332
  ret = ""
333
+ f = doc.at("./formattedref") and
334
+ return embedded ? f.children.to_xml : "<p>#{f.children.to_xml}</p>"
335
+
322
336
  type = type(doc)
323
337
  container = doc.at("./relation[@type='includedIn']")
324
- if container && date(doc) && !date(container)
325
- container("./bibitem") <<
326
- ( doc.at("./date[@type = 'issued']").remove || doc.at("./date[@type = 'circulated']").remove )
338
+ if container && !date(doc) && date(container&.at("./bibitem"))
339
+ doc <<
340
+ ( container&.at("./bibitem/date[@type = 'issued' or @type = 'published' or @type = 'circulated']")&.remove )
327
341
  end
328
342
  ser = series_title(doc)
329
343
  dr = draft(doc)
@@ -338,7 +352,7 @@ module Iso690Render
338
352
  if dr
339
353
  mdy = MMMddyyyy(date(doc)) and ret += wrap(mdy, " (", ")")
340
354
  else
341
- yr = year(date(doc)) and ret += wrap(yr, " (", ")")
355
+ yr = year(date(doc)) and ret += wrap(yr, " (", ")")
342
356
  end
343
357
  ret += included(type) ? wrap(title(doc)) : wrap(title(doc), " <I>", "</I>.")
344
358
  ret += wrap(medium(doc), " [", "].")
@@ -349,13 +363,13 @@ module Iso690Render
349
363
  ret += " Draft (#{dr})"
350
364
  end
351
365
  ret += wrap(series(doc, type), " ", "")
352
- ret += "," if series(doc, type) && date(doc)
366
+ ret += "," if !series(doc, type).empty? && date(doc)
353
367
  ret += wrap(date(doc))
354
368
  ret += wrap(standardidentifier(doc)) unless is_nist(doc)
355
369
  ret += wrap(uri(doc))
356
- ret += wrap(accessLocation(doc), "At: ", ".")
370
+ ret += wrap(accessLocation(doc), " At: ", ".")
357
371
  if container
358
- ret += wrap(parse(container.at("./bibitem").to_xml, true), " In:", "")
372
+ ret += wrap(parse(container.at("./bibitem"), true), " In: ", "")
359
373
  locality = container.xpath("./locality")
360
374
  locality.empty? and locality = doc.xpath("./extent")
361
375
  ret += wrap(extent(locality))
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  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: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-19 00:00:00.000000000 Z
11
+ date: 2019-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -354,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
354
354
  version: '0'
355
355
  requirements: []
356
356
  rubyforge_project:
357
- rubygems_version: 2.7.7
357
+ rubygems_version: 2.7.6
358
358
  signing_key:
359
359
  specification_version: 4
360
360
  summary: Metanorma NIST gem.