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.
@@ -13,7 +13,8 @@ module IsoDoc
13
13
  super
14
14
  end
15
15
 
16
- def convert1(docxml, filename, dir)
16
+ def convert1(docxml, filename, dir)
17
+ @bibliographycount = docxml.xpath(ns("//bibliography/references | //annex/references | //bibliography/clause/references")).size
17
18
  FileUtils.cp html_doc_path("logo.png"), "#{@localdir}/logo.png"
18
19
  FileUtils.cp html_doc_path("deptofcommerce.png"),
19
20
  "#{@localdir}/deptofcommerce.png"
@@ -24,9 +25,9 @@ module IsoDoc
24
25
  {
25
26
  bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
26
27
  '"Times New Roman",serif'),
27
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
28
- '"Arial",sans-serif'),
29
- monospacefont: '"Courier New",monospace'
28
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
29
+ '"Arial",sans-serif'),
30
+ monospacefont: '"Courier New",monospace'
30
31
  }
31
32
  end
32
33
 
@@ -221,7 +222,11 @@ module IsoDoc
221
222
  out.div do |div|
222
223
  #div.p **{ class: "h1Annex" } do |h1|
223
224
  div.h1 do |h1|
224
- f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
225
+ if @bibliographycount == 1
226
+ h1 << "References"
227
+ else
228
+ f&.at(ns("./title"))&.children.each { |n| parse(n, h1) }
229
+ end
225
230
  end
226
231
  f.elements.reject do |e|
227
232
  ["reference", "title", "bibitem"].include? e.name
@@ -459,6 +464,8 @@ module IsoDoc
459
464
 
460
465
  def info(isoxml, out)
461
466
  @meta.keywords isoxml, out
467
+ @meta.series isoxml, out
468
+ @meta.commentperiod isoxml, out
462
469
  super
463
470
  end
464
471
 
@@ -491,7 +498,7 @@ module IsoDoc
491
498
  end
492
499
  end
493
500
 
494
- def middle_section_asset_names(d)
501
+ def middle_section_asset_names(d)
495
502
  middle_sections =
496
503
  "//xmlns:preface/child::* | //xmlns:sections/child::*"
497
504
  sequential_asset_names(d.xpath(middle_sections))
@@ -593,7 +600,11 @@ module IsoDoc
593
600
  div.h1 **{ class: "Annex" } do |t|
594
601
  t << "#{get_anchors[annex['id']][:label]} &mdash; "
595
602
  t.b do |b|
596
- name&.children&.each { |c2| parse(c2, b) }
603
+ if @bibliographycount == 1 && annex.at(ns("./references"))
604
+ b << "References"
605
+ else
606
+ name&.children&.each { |c2| parse(c2, b) }
607
+ end
597
608
  end
598
609
  end
599
610
  end
@@ -602,7 +613,71 @@ module IsoDoc
602
613
  "-"
603
614
  end
604
615
 
616
+ def annex_names(clause, num)
617
+ @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
618
+ xref: "#{@annex_lbl} #{num}", level: 1 }
619
+ clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
620
+ annex_names1(c, "#{num}.#{i + 1}", 2)
621
+ end
622
+ hierarchical_asset_names(clause, num)
623
+ end
624
+
625
+ def annex_names1(clause, num, level)
626
+ @anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
627
+ level: level, type: "clause" }
628
+ clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
629
+ annex_names1(c, "#{num}.#{i + 1}", level + 1)
630
+ end
631
+ end
632
+
633
+ def terms_parse(node, out)
634
+ out.div **attr_code(id: node["id"]) do |div|
635
+ node.at(ns("./title")) and
636
+ clause_parse_title(node, div, node.at(ns("./title")), out)
637
+ term_defs_boilerplate(div, node.xpath(ns(".//termdocsource")),
638
+ node.at(ns(".//term")), node.at(ns("./p")))
639
+ node.elements.each do |e|
640
+ parse(e, div) unless %w{title source}.include? e.name
641
+ end
642
+ end
643
+ end
644
+
645
+ def termdef_parse(node, out)
646
+ pref = node.at(ns("./preferred"))
647
+ out.table **{ class: "terms_dl" } do |dl|
648
+ dl.tr do |tr|
649
+ tr.td **{ valign: "top", align: "left" } do |dt|
650
+ pref.children.each { |n| parse(n, dt) }
651
+ end
652
+ set_termdomain("")
653
+ tr.td **{ valign: "top" } do |dd|
654
+ node.children.each { |n| parse(n, dd) unless n.name == "preferred" }
655
+ end
656
+ end
657
+ end
658
+ end
605
659
 
660
+ def term_cleanup(docxml)
661
+ docxml.xpath("//table[@class = 'terms_dl']").each do |d|
662
+ prev = d.previous_element
663
+ next unless prev.name == "table" and prev["class"] == "terms_dl"
664
+ d.children.each { |n| prev.add_child(n.remove) }
665
+ d.remove
666
+ end
667
+ docxml
668
+ end
669
+
670
+ def bibliography_parse(node, out)
671
+ title = node&.at(ns("./title"))&.text || ""
672
+ out.div do |div|
673
+ node.parent.name == "annex" or
674
+ div.h2 title, **{ class: "Section3" }
675
+ node.elements.reject do |e|
676
+ ["reference", "title", "bibitem"].include? e.name
677
+ end.each { |e| parse(e, div) }
678
+ biblio_list(node, div, true)
679
+ end
680
+ end
606
681
  end
607
682
  end
608
683
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  Metanorma NIST gem.
14
14
  DESCRIPTION
15
15
 
16
- spec.homepage = "https://github.com/riboseinc/metanorma-nist"
16
+ spec.homepage = "https://github.com/metanorma/metanorma-nist"
17
17
  spec.license = "BSD-2-Clause"
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency "metanorma-standoc", "~> 1.1.0"
31
31
  spec.add_dependency "isodoc", "~> 0.9.0"
32
+ spec.add_dependency "twitter_cldr"
32
33
 
33
34
  spec.add_development_dependency "bundler", "~> 2.0.1"
34
35
  spec.add_development_dependency "byebug", "~> 9.1"
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.0.4
4
+ version: 0.0.5
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-02-25 00:00:00.000000000 Z
11
+ date: 2019-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: twitter_cldr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -251,6 +265,7 @@ files:
251
265
  - LICENSE
252
266
  - README.adoc
253
267
  - Rakefile
268
+ - appveyor.yml
254
269
  - bin/console
255
270
  - bin/rspec
256
271
  - bin/setup
@@ -261,6 +276,7 @@ files:
261
276
  - lib/asciidoctor/nist/isodoc.rng
262
277
  - lib/asciidoctor/nist/isostandard.rng
263
278
  - lib/asciidoctor/nist/nist.rng
279
+ - lib/asciidoctor/nist/reqt.rng
264
280
  - lib/isodoc/nist/html/commerce-logo-color.png
265
281
  - lib/isodoc/nist/html/deptofcommerce.png
266
282
  - lib/isodoc/nist/html/header.html
@@ -284,7 +300,7 @@ files:
284
300
  - lib/metanorma/nist/processor.rb
285
301
  - lib/metanorma/nist/version.rb
286
302
  - metanorma-nist.gemspec
287
- homepage: https://github.com/riboseinc/metanorma-nist
303
+ homepage: https://github.com/metanorma/metanorma-nist
288
304
  licenses:
289
305
  - BSD-2-Clause
290
306
  metadata: {}