metanorma-standoc 1.1.9 → 1.2.0

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: e60988dd72d65a660d97266b8e2a0afd786b619f97e7cf948e040a1b31f7d6fc
4
- data.tar.gz: ef5405bcb35b0250cbfbbf30b092a4dd0f0cbaf4435edfab0b8dcf4ddd46cc14
3
+ metadata.gz: 30d5bcdf81251b8337ccbc89b87c995e53f2899277d814e6668f20c88b4cfd2e
4
+ data.tar.gz: 85b27e1f408c227f92aa9912e8937867583e25dfaec0fb05b7d644dff19fd514
5
5
  SHA512:
6
- metadata.gz: e2af11f2fecbfa996d3fda092aabcfd3803117f98afdff33471e27182db1931359acb16379eaa29a998ae3667eea31e3622029cba4c110ab1daa6063d0cf9b2c
7
- data.tar.gz: 3f19ae9393a94ceb2dd768f926f14f6ea798ae8be156f9aad3fa578d9eeb93e8e7d82a0f9af1d0eeefe53cb3e5bc4578cd3e959df268c06e0dbe4274dce1fc31
6
+ metadata.gz: 51cd7259dad7810f4496001fe1013ba6e88bb0cbc033babbba19ce545c3b9210abc7fb169aefc26c850db72493e5016316c6b60fa7f712c04872ff7a0b48bfad
7
+ data.tar.gz: 21c1588e83613777b5e25eb412eaf0d4cdaf82b927bdb4f824751af139585c4416a40779fe243505d180ea3db97c2647f393c4d73be09b06b540adba175d8e43
data/Gemfile CHANGED
@@ -3,7 +3,5 @@ Encoding.default_internal = Encoding::UTF_8
3
3
 
4
4
  source "https://rubygems.org"
5
5
 
6
- gem 'vcr', git: 'https://github.com/vcr/vcr.git', ref: 'a0bb140184e8518baad640a705e04155911bf31f'
7
-
8
6
  # Specify your gem's dependencies in gemspec
9
7
  gemspec
data/Gemfile.lock CHANGED
@@ -1,20 +1,14 @@
1
- GIT
2
- remote: https://github.com/vcr/vcr.git
3
- revision: a0bb140184e8518baad640a705e04155911bf31f
4
- ref: a0bb140184e8518baad640a705e04155911bf31f
5
- specs:
6
- vcr (4.0.0)
7
-
8
1
  PATH
9
2
  remote: .
10
3
  specs:
11
- metanorma-standoc (1.1.9)
4
+ metanorma-standoc (1.2.0)
12
5
  asciidoctor (~> 1.5.7)
13
6
  concurrent-ruby
14
- html2doc (~> 0.8.0)
7
+ html2doc (~> 0.8.11)
15
8
  iev (~> 0.2.1)
16
- isodoc (~> 0.9.0)
17
- relaton (~> 0.3.1)
9
+ isodoc (~> 0.10.0)
10
+ relaton (~> 0.4.0)
11
+ relaton-cli (~> 0.2.0)
18
12
  ruby-jing
19
13
  sterile (~> 1.0.14)
20
14
  unicode2latex (~> 0.0.1)
@@ -37,16 +31,12 @@ GEM
37
31
  crack (0.4.3)
38
32
  safe_yaml (~> 1.0.0)
39
33
  diff-lcs (1.3)
40
- docile (1.3.1)
34
+ docile (1.3.2)
41
35
  equivalent-xml (0.6.0)
42
36
  nokogiri (>= 1.4.3)
43
- ffi (1.9.25)
37
+ ffi (1.11.1)
44
38
  formatador (0.2.5)
45
39
  gb-agencies (0.0.5)
46
- gbbib (0.4.4)
47
- cnccs (~> 0.1.1)
48
- gb-agencies (~> 0.0.1)
49
- iso-bib-item (~> 0.4.2)
50
40
  guard (2.15.0)
51
41
  formatador (>= 0.2.4)
52
42
  listen (>= 2.7, < 4.0)
@@ -61,8 +51,8 @@ GEM
61
51
  guard (~> 2.1)
62
52
  guard-compat (~> 1.1)
63
53
  rspec (>= 2.99.0, < 4.0)
64
- hashdiff (0.3.9)
65
- html2doc (0.8.10)
54
+ hashdiff (0.4.0)
55
+ html2doc (0.8.11)
66
56
  asciimath (~> 1.0.7)
67
57
  htmlentities (~> 4.3.4)
68
58
  image_size
@@ -72,32 +62,19 @@ GEM
72
62
  uuidtools
73
63
  htmlentities (4.3.4)
74
64
  httpclient (2.8.3)
75
- iecbib (0.2.2)
76
- addressable
77
- iso-bib-item (~> 0.4.2)
78
- ietfbib (0.4.6)
79
- iso-bib-item (~> 0.4.2)
80
65
  iev (0.2.2)
81
66
  nokogiri
82
- image_size (2.0.0)
83
- iso-bib-item (0.4.5)
84
- isoics (~> 0.1.6)
85
- nokogiri (~> 1.8.4)
86
- ruby_deep_clone (~> 0.8.0)
87
- isobib (0.4.4)
88
- algoliasearch
89
- iecbib (~> 0.2.1)
90
- iso-bib-item (~> 0.4.2)
91
- isodoc (0.9.23)
67
+ image_size (2.0.1)
68
+ isodoc (0.10.0)
92
69
  asciimath
93
- html2doc (~> 0.8.6)
70
+ html2doc (~> 0.8.11)
94
71
  htmlentities (~> 4.3.4)
95
72
  liquid
96
73
  metanorma (~> 0.3.0)
97
74
  nokogiri (>= 1)
98
75
  rake (~> 12.0)
99
76
  roman-numerals
100
- sassc (~> 1.12.1)
77
+ sassc (~> 2)
101
78
  thread_safe
102
79
  uuidtools
103
80
  isoics (0.1.7)
@@ -117,8 +94,6 @@ GEM
117
94
  mime-types-data (3.2019.0331)
118
95
  mini_portile2 (2.3.0)
119
96
  nenv (0.3.0)
120
- nistbib (0.1.3)
121
- relaton-bib (~> 0.1.0)
122
97
  nokogiri (1.8.5)
123
98
  mini_portile2 (~> 2.3.0)
124
99
  notiffany (0.1.1)
@@ -132,36 +107,64 @@ GEM
132
107
  pry (0.12.2)
133
108
  coderay (~> 1.1.0)
134
109
  method_source (~> 0.9.0)
135
- public_suffix (3.0.3)
110
+ public_suffix (3.1.0)
136
111
  rainbow (3.0.0)
137
112
  rake (12.3.2)
138
113
  rb-fsevent (0.10.3)
139
114
  rb-inotify (0.10.0)
140
115
  ffi (~> 1.0)
141
- relaton (0.3.4)
116
+ relaton (0.4.0)
117
+ algoliasearch
118
+ relaton-gb (~> 0.5.0)
119
+ relaton-iec (~> 0.3.0)
120
+ relaton-ietf (~> 0.5.0)
121
+ relaton-iso (~> 0.5.0)
122
+ relaton-iso-bib (~> 0.2.0)
123
+ relaton-itu (~> 0.2.0)
124
+ relaton-nist (~> 0.2.0)
125
+ relaton-bib (0.2.1)
126
+ addressable
127
+ nokogiri (~> 1.8.4)
128
+ relaton-cli (0.2.0)
129
+ liquid
130
+ relaton (~> 0.4)
131
+ thor
132
+ relaton-gb (0.5.0)
133
+ cnccs (~> 0.1.1)
134
+ gb-agencies (~> 0.0.1)
135
+ relaton-iso-bib (~> 0.2.0)
136
+ relaton-iec (0.3.0)
137
+ addressable
138
+ relaton-iso-bib (~> 0.2.0)
139
+ relaton-ietf (0.5.0)
140
+ relaton-iso-bib (~> 0.2.0)
141
+ relaton-iso (0.5.0)
142
142
  algoliasearch
143
- gbbib (~> 0.4.0)
144
- iecbib (~> 0.2.0)
145
- ietfbib (~> 0.4.2)
146
- iso-bib-item (~> 0.4.2)
147
- isobib (~> 0.4.0)
148
- nistbib (~> 0.1.1)
149
- relaton-bib (0.1.1)
143
+ relaton-iec (~> 0.3.0)
144
+ relaton-iso-bib (~> 0.2.0)
145
+ relaton-iso-bib (0.2.1)
146
+ isoics (~> 0.1.6)
150
147
  nokogiri (~> 1.8.4)
148
+ relaton-bib (~> 0.2.0)
149
+ ruby_deep_clone (~> 0.8.0)
150
+ relaton-itu (0.2.0)
151
+ relaton-iso-bib (~> 0.2.0)
152
+ relaton-nist (0.2.0)
153
+ relaton-bib (~> 0.2.0)
151
154
  roman-numerals (0.3.0)
152
155
  rspec (3.8.0)
153
156
  rspec-core (~> 3.8.0)
154
157
  rspec-expectations (~> 3.8.0)
155
158
  rspec-mocks (~> 3.8.0)
156
- rspec-core (3.8.0)
159
+ rspec-core (3.8.1)
157
160
  rspec-support (~> 3.8.0)
158
- rspec-expectations (3.8.3)
161
+ rspec-expectations (3.8.4)
159
162
  diff-lcs (>= 1.2.0, < 2.0)
160
163
  rspec-support (~> 3.8.0)
161
- rspec-mocks (3.8.0)
164
+ rspec-mocks (3.8.1)
162
165
  diff-lcs (>= 1.2.0, < 2.0)
163
166
  rspec-support (~> 3.8.0)
164
- rspec-support (3.8.0)
167
+ rspec-support (3.8.2)
165
168
  rubocop (0.54.0)
166
169
  parallel (~> 1.10)
167
170
  parser (>= 2.5)
@@ -171,18 +174,13 @@ GEM
171
174
  unicode-display_width (~> 1.0, >= 1.0.1)
172
175
  ruby-jing (0.0.1)
173
176
  optout (>= 0.0.2)
174
- ruby-progressbar (1.10.0)
177
+ ruby-progressbar (1.10.1)
175
178
  ruby_deep_clone (0.8.0)
176
179
  ruby_dep (1.5.0)
177
180
  safe_yaml (1.0.5)
178
- sass (3.7.4)
179
- sass-listen (~> 4.0.0)
180
- sass-listen (4.0.0)
181
- rb-fsevent (~> 0.9, >= 0.9.4)
182
- rb-inotify (~> 0.9, >= 0.9.7)
183
- sassc (1.12.1)
184
- ffi (~> 1.9.6)
185
- sass (>= 3.3.0)
181
+ sassc (2.0.1)
182
+ ffi (~> 1.9)
183
+ rake
186
184
  shellany (0.0.1)
187
185
  simplecov (0.16.1)
188
186
  docile (~> 1.1)
@@ -194,13 +192,14 @@ GEM
194
192
  thor (0.20.3)
195
193
  thread_safe (0.3.6)
196
194
  timecop (0.9.1)
197
- unicode-display_width (1.5.0)
195
+ unicode-display_width (1.6.0)
198
196
  unicode2latex (0.0.2)
199
197
  uuidtools (2.1.5)
200
- webmock (3.5.1)
198
+ vcr (5.0.0)
199
+ webmock (3.6.0)
201
200
  addressable (>= 2.3.6)
202
201
  crack (>= 0.3.2)
203
- hashdiff
202
+ hashdiff (>= 0.4.0, < 2.0.0)
204
203
 
205
204
  PLATFORMS
206
205
  ruby
@@ -218,7 +217,7 @@ DEPENDENCIES
218
217
  rubocop (= 0.54.0)
219
218
  simplecov (~> 0.15)
220
219
  timecop (~> 0.9)
221
- vcr!
220
+ vcr (~> 5.0.0)
222
221
  webmock
223
222
 
224
223
  BUNDLED WITH
@@ -5,7 +5,6 @@ require "json"
5
5
  require "pathname"
6
6
  require "open-uri"
7
7
  require "pp"
8
- require "sass"
9
8
  require "isodoc"
10
9
  require "relaton"
11
10
  require "fileutils"
@@ -106,15 +105,14 @@ module Asciidoctor
106
105
  end
107
106
 
108
107
  def init_bib_caches(node)
109
- unless (@no_isobib_cache || @no_isobib)
110
- globalname = global_bibliocache_name unless node.attr("local-cache-only")
111
- localname = local_bibliocache_name(node.attr("local-cache") || node.attr("local-cache-only"))
112
- if node.attr("flush-caches")
113
- FileUtils.rm_f globalname unless globalname.nil?
114
- FileUtils.rm_f localname unless localname.nil?
115
- end
116
- end
117
- @bibdb = Relaton::Db.new(globalname, localname) unless @no_isobib
108
+ return if @no_isobib
109
+ global = !@no_isobib_cache && !node.attr("local-cache-only")
110
+ local = node.attr("local-cache") || node.attr("local-cache-only")
111
+ local = nil if @no_isobib_cache
112
+ @bibdb = Relaton::DbCache.init_bib_caches(
113
+ local_cache: local,
114
+ flush_caches: node.attr("flush-caches"),
115
+ global_cache: global)
118
116
  end
119
117
 
120
118
  def init_iev_caches(node)
@@ -177,7 +175,7 @@ module Asciidoctor
177
175
  end
178
176
 
179
177
  def front(node, xml)
180
- xml.bibdata **attr_code(type: doctype(node)) do |b|
178
+ xml.bibdata **attr_code(type: "standard") do |b|
181
179
  metadata node, b
182
180
  end
183
181
  end
@@ -35,7 +35,28 @@
35
35
  </define>
36
36
  <define name="status">
37
37
  <element name="status">
38
- <ref name="LocalizedString"/>
38
+ <ref name="stage"/>
39
+ <optional>
40
+ <ref name="substage"/>
41
+ </optional>
42
+ <optional>
43
+ <ref name="iteration"/>
44
+ </optional>
45
+ </element>
46
+ </define>
47
+ <define name="stage">
48
+ <element name="stage">
49
+ <text/>
50
+ </element>
51
+ </define>
52
+ <define name="substage">
53
+ <element name="substage">
54
+ <text/>
55
+ </element>
56
+ </define>
57
+ <define name="iteration">
58
+ <element name="iteration">
59
+ <text/>
39
60
  </element>
40
61
  </define>
41
62
  <define name="language">
@@ -523,9 +544,9 @@
523
544
  <zeroOrMore>
524
545
  <ref name="script"/>
525
546
  </zeroOrMore>
526
- <optional>
547
+ <zeroOrMore>
527
548
  <ref name="abstract"/>
528
- </optional>
549
+ </zeroOrMore>
529
550
  <optional>
530
551
  <ref name="status"/>
531
552
  </optional>
@@ -10,11 +10,17 @@ module Asciidoctor
10
10
  { id: Utils::anchor_or_uuid(node) }
11
11
  end
12
12
 
13
+ def id_unnum_attr(node)
14
+ attr_code( id: Utils::anchor_or_uuid(node),
15
+ unnumbered: node.option?("unnumbered") ? "true" : nil )
16
+ end
17
+
13
18
  # open block is a container of multiple blocks,
14
19
  # treated as a single block.
15
20
  # We append each contained block to its parent
16
21
  def open(node)
17
- Utils::reqt_subpart(node.attr("style")) and
22
+ role = node.role || node.attr("style")
23
+ Utils::reqt_subpart(role) and
18
24
  return requirement_subpart(node)
19
25
  result = []
20
26
  node.blocks.each do |b|
@@ -24,7 +30,7 @@ module Asciidoctor
24
30
  end
25
31
 
26
32
  def requirement_subpart(node)
27
- name = node.attr("style")
33
+ name = node.role || node.attr("style")
28
34
  noko do |xml|
29
35
  xml.send name, **attr_code(exclude: node.option?("exclude"),
30
36
  type: node.attr("type")) do |o|
@@ -46,7 +52,7 @@ module Asciidoctor
46
52
  def stem(node)
47
53
  stem_content = node.lines.join("\n")
48
54
  noko do |xml|
49
- xml.formula **id_attr(node) do |s|
55
+ xml.formula **id_unnum_attr(node) do |s|
50
56
  stem_parse(stem_content, s, node.style.to_sym)
51
57
  end
52
58
  end
@@ -144,11 +150,12 @@ module Asciidoctor
144
150
 
145
151
  def example(node)
146
152
  return term_example(node) if in_terms?
147
- return requirement(node, "recommendation") if node.attr("style") == "recommendation"
148
- return requirement(node, "requirement") if node.attr("style") == "requirement"
149
- return requirement(node, "permission") if node.attr("style") == "permission"
153
+ role = node.role || node.attr("style")
154
+ return requirement(node, "recommendation") if role == "recommendation"
155
+ return requirement(node, "requirement") if role == "requirement"
156
+ return requirement(node, "permission") if role == "permission"
150
157
  noko do |xml|
151
- xml.example **id_attr(node) do |ex|
158
+ xml.example **id_unnum_attr(node) do |ex|
152
159
  wrap_in_para(node, ex)
153
160
  end
154
161
  end.join("\n")
@@ -176,6 +183,7 @@ module Asciidoctor
176
183
  def reqt_attributes(node)
177
184
  {
178
185
  id: Utils::anchor_or_uuid,
186
+ unnumbered: node.option?("unnumbered") ? "true" : nil,
179
187
  obligation: node.attr("obligation"),
180
188
  filename: node.attr("filename")
181
189
  }
@@ -233,7 +241,7 @@ module Asciidoctor
233
241
 
234
242
  def image(node)
235
243
  noko do |xml|
236
- xml.figure **id_attr(node) do |f|
244
+ xml.figure **id_unnum_attr(node) do |f|
237
245
  figure_title(node, f)
238
246
  f.image **attr_code(image_attributes(node))
239
247
  end
@@ -36,6 +36,7 @@ module Asciidoctor
36
36
  figure_cleanup(xmldoc)
37
37
  ref_cleanup(xmldoc)
38
38
  note_cleanup(xmldoc)
39
+ ref_dl_cleanup(xmldoc)
39
40
  normref_cleanup(xmldoc)
40
41
  biblio_cleanup(xmldoc)
41
42
  reference_names(xmldoc)
@@ -1,4 +1,5 @@
1
1
  require "set"
2
+ require "relaton-cli"
2
3
 
3
4
  module Asciidoctor
4
5
  module Standoc
@@ -122,7 +123,7 @@ module Asciidoctor
122
123
  end
123
124
 
124
125
  # converts generic IEV citation to citation of IEC 60050-n
125
- # assumes IEV citations are of form
126
+ # assumes IEV citations are of form
126
127
  # <eref type="inline" bibitemid="a" citeas="IEC 60050">
127
128
  # <locality type="clause"><referenceFrom>101-01-01</referenceFrom></locality></eref>
128
129
  def linksIev2iec60050part(xmldoc)
@@ -159,6 +160,84 @@ module Asciidoctor
159
160
  parts = linksIev2iec60050part(xmldoc)
160
161
  refsIev2iec60050part(xmldoc, parts, iev)
161
162
  end
163
+
164
+ def ref_dl_cleanup(xmldoc)
165
+ xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
166
+ bib = dl_bib_extract(c) or next
167
+ b = Nokogiri::XML::Node.new('bibitem', xmldoc)
168
+ b["id"] = bib["ref"]&.strip
169
+ b["type"] = bib["doctype"]&.strip
170
+ b << %Q[<title format="text/plain">#{bib['title']}</title>]
171
+ #b << extract_from_p("docidentifier", bib, "docidentifier")
172
+
173
+ b << %Q[<docidentifier>#{bib['docidentifier']}</docidentifier>]
174
+
175
+ Array(bib["publisher"]).each do |name|
176
+ b << %Q[<contributor><role type="publisher"/><organization>
177
+ <name>#{name}</name>
178
+ </organization></contributor>]
179
+ #{extract_from_p("publisher", bib, "name")}
180
+ end
181
+
182
+ Array(bib["author"]).each do |name|
183
+ b << %Q[<contributor><role type="author"/><person>
184
+ <name><completename>#{name}</completename></name>
185
+ </person></contributor>]
186
+ end
187
+ c.replace(b)
188
+ end
189
+ end
190
+
191
+ def ref_dl_cleanup(xmldoc)
192
+ xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
193
+ bib = dl_bib_extract(c) or next
194
+ bibitemxml = Relaton::Bibdata.new(bib).to_xml or next
195
+ # TODO move this into relaton-cli
196
+ bibitem = Nokogiri::XML(bibitemxml)
197
+ bibitem.root.name = "bibitem"
198
+ bibitem.root["id"] = bib["ref"]&.strip
199
+ bibitem.root["type"] = bib["doctype"]&.strip
200
+ c.replace(bibitem.root)
201
+ end
202
+ end
203
+
204
+ def extract_from_p(tag, bib, key)
205
+ return unless bib[tag]
206
+ "<#{key}>#{bib[tag].at('p').children}</#{key}>"
207
+ end
208
+
209
+ # if the content is a single paragraph, replace it with its children
210
+ def p_unwrap(p)
211
+ elems = p.elements
212
+ if elems.size == 1 && elems[0].name == "p"
213
+ elems[0].children.to_xml
214
+ else
215
+ p.to_xml
216
+ end
217
+ end
218
+
219
+ def dd_bib_extract(dtd)
220
+ elems = dtd.remove.elements
221
+ return p_unwrap(dtd) unless elems.size == 1 && elems[0].name == "ol"
222
+ ret = []
223
+ elems[0].xpath("./li").each do |li|
224
+ ret << p_unwrap(li)
225
+ end
226
+ ret
227
+ end
228
+
229
+ # definition list, with at most one level of unordered lists
230
+ def dl_bib_extract(c)
231
+ dl = c.at("./dl") or return
232
+ bib = {}
233
+ key = ""
234
+ dl.xpath("./dt | ./dd").each do |dtd|
235
+ key = dtd.text if dtd.name == "dt"
236
+ bib[key] = dd_bib_extract(dtd) if dtd.name == "dd"
237
+ end
238
+ bib["title"] = c.at("./title").remove.children
239
+ bib
240
+ end
162
241
  end
163
242
  end
164
243
  end