metanorma-nist 1.2.0 → 1.2.5

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.0"
3
+ VERSION = "1.2.5"
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.0
4
+ version: 1.2.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: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-10-11 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