metanorma-nist 1.2.1 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,10 +4,6 @@ require_relative "render_contributors"
4
4
  require_relative "render_dates"
5
5
 
6
6
  module Iso690Render
7
- =begin
8
- Out of scope: Provenance (differentiating elements by @source in rendering)
9
- =end
10
-
11
7
  def self.render(bib, embedded = false)
12
8
  docxml = Nokogiri::XML(bib)
13
9
  docxml.remove_namespaces!
@@ -37,7 +37,7 @@ module Iso690Render
37
37
  completename = person.at("./name/completename")
38
38
  return completename.text if completename
39
39
  surname = person.at("./name/surname")
40
- initials = person.xpath("./name/initials")
40
+ initials = person.xpath("./name/initial")
41
41
  forenames = person.xpath("./name/forename")
42
42
  #given = []
43
43
  #forenames.each { |x| given << x.text }
@@ -1,6 +1,18 @@
1
1
  module IsoDoc
2
2
  module NIST
3
3
  module BaseConvert
4
+ def keywords(docxml, out)
5
+ f = docxml.at(ns("//preface/clause[@type = 'keyword']")) || return
6
+ preface1(f, f&.at(ns("./title")), false, out)
7
+ end
8
+
9
+ def skip_render(c, isoxml)
10
+ return false unless c.name == "reviewernote"
11
+ status = isoxml&.at(ns("//bibdata/status/stage"))&.text
12
+ return true if status.nil?
13
+ /^final/.match status
14
+ end
15
+
4
16
  def abstract(isoxml, out)
5
17
  f = isoxml.at(ns("//preface/abstract")) || return
6
18
  out.div **attr_code(id: f["id"]) do |s|
@@ -11,13 +23,13 @@ module IsoDoc
11
23
  end
12
24
 
13
25
  FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or "\
14
- "local-name() = 'foreword') or @type = 'keyword']".freeze
26
+ "local-name() = 'foreword' or @type = 'keyword')]".freeze
15
27
 
16
28
  # All "[preface]" sections should have class "IntroTitle" to prevent
17
29
  # page breaks, but for the Exec Summary
18
30
  def preface(isoxml, out)
19
31
  isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
20
- next if skip_render(c, isoxml)
32
+ next if skip_render(c, isoxml) || !is_clause?(c.name)
21
33
  title = c&.at(ns("./title"))
22
34
  patent = ["Call for Patent Claims",
23
35
  "Patent Disclosure Notice"].include? title&.text
@@ -37,12 +49,6 @@ module IsoDoc
37
49
  end
38
50
  end
39
51
 
40
- def middle(isoxml, out)
41
- clause isoxml, out
42
- bibliography isoxml, out
43
- annex isoxml, out
44
- end
45
-
46
52
  def foreword(isoxml, out)
47
53
  f = isoxml.at(ns("//foreword")) || return
48
54
  out.div **attr_code(id: f["id"]) do |s|
@@ -53,6 +59,11 @@ module IsoDoc
53
59
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
54
60
  end
55
61
  end
62
+
63
+ def is_clause?(name)
64
+ return true if %w(reviewernote executivesummary).include? name
65
+ super
66
+ end
56
67
  end
57
68
  end
58
69
  end
@@ -14,6 +14,10 @@ module IsoDoc
14
14
  def initialize(options)
15
15
  @libdir = File.dirname(__FILE__)
16
16
  super
17
+ @wordToClevels = options[:doctoclevels].to_i
18
+ @wordToClevels = 3 if @wordToClevels.zero?
19
+ @htmlToClevels = options[:htmltoclevels].to_i
20
+ @htmlToClevels = 3 if @htmlToClevels.zero?
17
21
  end
18
22
 
19
23
  def convert1(docxml, filename, dir)
@@ -62,8 +66,10 @@ module IsoDoc
62
66
  body.div **{ class: "WordSection2" } do |div2|
63
67
  @prefacenum = 0
64
68
  info docxml, div2
69
+ preface_block docxml, div2
65
70
  foreword docxml, div2
66
71
  abstract docxml, div2
72
+ keywords docxml, div2
67
73
  boilerplate docxml, div2
68
74
  preface docxml, div2
69
75
  div2.p { |p| p << "&nbsp;" } # placeholder
@@ -71,6 +77,24 @@ module IsoDoc
71
77
  section_break(body)
72
78
  end
73
79
 
80
+ def toWord(result, filename, dir, header)
81
+ result = populate_template(result, :word)
82
+ result = from_xhtml(word_cleanup(to_xhtml(result)))
83
+ unless @landscapestyle.nil? || @landscapestyle.empty?
84
+ @wordstylesheet&.open
85
+ @wordstylesheet&.write(@landscapestyle)
86
+ @wordstylesheet&.close
87
+ end
88
+ Html2Doc.process(result, filename: filename,
89
+ stylesheet: @wordstylesheet&.path,
90
+ header_file: header&.path, dir: dir,
91
+ asciimathdelims: [@openmathdelim, @closemathdelim],
92
+ liststyles: { ul: @ulstyle, ol: @olstyle,
93
+ steps: "l4" })
94
+ header&.unlink
95
+ @wordstylesheet&.unlink
96
+ end
97
+
74
98
  def authority_cleanup(docxml)
75
99
  docxml&.xpath("//div[@class = 'authority']//h1 | "\
76
100
  "//div[@class = 'authority']//h2")&.each do |h|
@@ -125,6 +149,7 @@ module IsoDoc
125
149
  end
126
150
 
127
151
  def word_annex_cleanup(docxml)
152
+ word_annex_cleanup1(docxml, 1)
128
153
  word_annex_cleanup1(docxml, 2)
129
154
  word_annex_cleanup1(docxml, 3)
130
155
  word_annex_cleanup1(docxml, 4)
@@ -165,6 +190,22 @@ module IsoDoc
165
190
  end
166
191
  end
167
192
 
193
+ def glossary_parse(node, out)
194
+ out.table **attr_code(id: node["id"], class: "terms_dl") do |t|
195
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
196
+ t.tr do |v|
197
+ v.td **attr_code(id: dt["id"], valign: "top", align: "left") do |term|
198
+ dt_parse(dt, term)
199
+ end
200
+ v.td **attr_code(id: dd["id"], valign: "top") do |listitem|
201
+ dd.children.each { |n| parse(n, listitem) }
202
+ end
203
+ end
204
+ end
205
+ end
206
+ node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
207
+ end
208
+
168
209
  include BaseConvert
169
210
  include Init
170
211
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.6"
4
4
  end
5
5
  end
@@ -30,7 +30,7 @@ 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.5.0"
33
+ spec.add_dependency "metanorma-standoc", "~> 1.6.0"
34
34
  spec.add_dependency "isodoc", "~> 1.2.0"
35
35
  #spec.add_dependency "relaton-nist", "~> 0.3.0"
36
36
 
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.2.1
4
+ version: 1.2.6
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-08-14 00:00:00.000000000 Z
11
+ date: 2020-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.5.0
89
+ version: 1.6.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.5.0
96
+ version: 1.6.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: isodoc
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -257,9 +257,7 @@ executables: []
257
257
  extensions: []
258
258
  extra_rdoc_files: []
259
259
  files:
260
- - ".github/workflows/macos.yml"
261
- - ".github/workflows/ubuntu.yml"
262
- - ".github/workflows/windows.yml"
260
+ - ".github/workflows/rake.yml"
263
261
  - ".hound.yml"
264
262
  - ".rubocop.yml"
265
263
  - CODE_OF_CONDUCT.md
@@ -1,38 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- run: |
34
- sudo gem install bundler --force
35
- bundle install --jobs 4 --retry 3
36
- - name: Run specs
37
- run: |
38
- bundle exec rake
@@ -1,56 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- tags:
9
- - '*'
10
- pull_request:
11
- paths-ignore:
12
- - .github/workflows/macos.yml
13
- - .github/workflows/windows.yml
14
-
15
- jobs:
16
- test-linux:
17
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
18
- runs-on: ubuntu-latest
19
- continue-on-error: ${{ matrix.experimental }}
20
- strategy:
21
- fail-fast: false
22
- matrix:
23
- ruby: [ '2.6', '2.5', '2.4' ]
24
- experimental: [false]
25
- include:
26
- - ruby: '2.7'
27
- experimental: true
28
- steps:
29
- - uses: actions/checkout@master
30
- - name: Use Ruby
31
- uses: actions/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- - name: Update gems
35
- run: |
36
- gem install bundler
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake
41
- - name: Trigger repositories
42
- if: matrix.ruby == '2.6'
43
- env:
44
- GH_USERNAME: metanorma-ci
45
- GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
46
- run: |
47
- curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
48
- [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
49
- CLIENT_PAYLOAD=$(cat <<EOF
50
- "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
51
- EOF
52
- )
53
- for repo in $REPOS
54
- do
55
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
56
- done
@@ -1,40 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/ubuntu.yml
12
-
13
- jobs:
14
- test-windows:
15
- name: Test on Ruby ${{ matrix.ruby }} Windows
16
- runs-on: windows-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- shell: pwsh
34
- run: |
35
- gem install bundler
36
- bundle config --local path vendor/bundle
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake