metanorma-mpdf 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71bcc175d700c507ef9167ab50aeb47b4e5abdffd9b4e0b7cc9fdc21f0645bf9
4
- data.tar.gz: 460d396daf3dfbc9f0ddd5cc0e2cf8c64ead2e16e68a1b8923f1ebc8c5a38927
3
+ metadata.gz: 5f4eb229f4a2e784830c7475d8ae2758343a5ce585828f427f59ba5cde7f5006
4
+ data.tar.gz: 6b32629de2950aa5118b981a68cd329a0e0830656aae44ffac3c339657752ad8
5
5
  SHA512:
6
- metadata.gz: ed08198df8ce30ed889e01559aa415abc14d817c30ccd6db13a21d57aceda011b7afb70d03299c0c7cf6d5eae6f273d33ef809ad68a7c55e0fa6a50795c65052
7
- data.tar.gz: 5e3e26a1ffc02c10ab40441d0b7b3aa6d3cefc707cd23f1bcc7efab5364101059dc9e3ac1e36b87337d51f908a20be98093dd3483e6224bbb218edd4fc124f78
6
+ metadata.gz: e3022603c410b267d091078806e8a6794888ff286597277f71f0b5c8b7f1675d1cbd7b6fc59d78f894f61dc13357030d38cb7a46546dfa7dfce6ae87942cc19c
7
+ data.tar.gz: 92be4b9fbcd8b65a37554c8a53716f521979c46a08d7bb853a1bb2285b16cb0dd7ed50b06b524b17b25470dcbd1edd4c57926ac6e5de38757453f438f69bfc9d
@@ -4,6 +4,7 @@ language: ruby
4
4
  rvm:
5
5
  - 2.5
6
6
  - 2.4
7
+ - 2.3
7
8
  - ruby-head
8
9
  before_install:
9
10
  - gem install bundler -v 1.16.1
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Mpfd
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -252,61 +252,60 @@ module IsoDoc
252
252
  l10n("<b>#{@annex_lbl} #{num}</b>")
253
253
  end
254
254
 
255
- def clause_names(docxml, sect_num)
256
- q = "//clause[parent::sections]"\
257
- "[not(descendant::terms)]"
258
- @topnum = sect_num
255
+ def xclause_names(docxml, _sect_num)
256
+ q = "//clause[parent::sections]"
257
+ @topnum = nil
259
258
  docxml.xpath(ns(q)).each do |c|
260
259
  section_names(c, @topnum, 1)
261
260
  end
262
261
  end
263
262
 
264
- def section_naming(c, num, lvl, i)
265
- if c["guidance"] then section_names1(c, "#{num}E", lvl + 1)
266
- elsif c.parent["container"] then
267
- i+= 1
268
- section_names1(c, i, lvl)
269
- else
270
- i+= 1
271
- section_names1(c, "#{num}.#{i}", lvl + 1)
263
+ def clause_names(docxml, sect_num)
264
+ q = "//clause[parent::sections]"
265
+ @topnum = nil
266
+ lvl = 0
267
+ docxml.xpath(ns(q)).each do |c|
268
+ container_names(c, 0)
269
+ sect_num, lvl = sect_names(c, nil, sect_num, 0, lvl)
272
270
  end
273
- i
274
271
  end
275
272
 
276
- def section_names(clause, num, lvl)
277
- return num if clause.nil?
278
- num = num + 1
279
- @topnum = num unless clause["container"]
280
- @anchors[clause["id"]] = clause["container"] ?
281
- { label: nil, xref: clause.at(ns("./title"))&.text, level: 1 } :
282
- { label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
283
- i = 0
284
- i = @topnum if clause.parent["container"] && !clause["container"]
285
- if clause.parent["container"] && !clause["container"]
273
+ def container_names(clause, lvl)
274
+ if clause["container"]
275
+ @anchors[clause["id"]] =
276
+ { label: nil, xref: clause.at(ns("./title"))&.text, level: lvl+1 }
286
277
  end
287
278
  clause.xpath(ns("./clause | ./term | ./terms | "\
288
279
  "./definitions")).each do |c|
289
- i = section_naming(c, num, lvl, i)
280
+ container_names(c, clause["container"] ? lvl+1 : lvl)
290
281
  end
291
- num
292
282
  end
293
283
 
294
- def section_names1(clause, num, lvl)
295
- if clause.parent["container"] && !clause["container"]
296
- newsect = true
297
- if @topnum > 1
298
- num = @topnum + 1
299
- end
284
+ def sect_names(clause, num, i, lvl, prev_lvl)
285
+ return i if clause.nil?
286
+ curr = i
287
+ if clause["container"]
288
+ retlvl = lvl+1
289
+ else
290
+ retlvl = lvl
291
+ i+=1
292
+ curr = i
293
+ name = num.nil? ? i.to_s : "#{num}.#{i}"
294
+ @anchors[clause["id"]] = { label: name, xref: l10n("#{@clause_lbl} #{name}"), level: lvl+1 }
300
295
  end
301
- @anchors[clause["id"]] = clause["container"] ?
302
- { label: nil, xref: clause.at(ns("./title")), level: clause.ancestors("clause[@container]").length + 1 } :
303
- { label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
304
- i = 0
305
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).
306
- each do |c|
307
- i = section_naming(c, num, lvl, i)
296
+ prev = lvl
297
+ j = 0
298
+ clause.xpath(ns("./clause | ./term | ./terms | "\
299
+ "./definitions")).each do |c|
300
+ if clause["container"]
301
+ i, lvl = sect_names(c, num, i, lvl, lvl)
302
+ else
303
+ j, prev = sect_names(c, name, j, lvl+1, prev)
304
+ end
308
305
  end
309
- @topnum = num if newsect
306
+ i = j if j >0
307
+ i = curr if lvl < prev
308
+ [i, prev]
310
309
  end
311
310
 
312
311
  def annex_naming(c, num, lvl, i)
@@ -256,52 +256,52 @@ module IsoDoc
256
256
  l10n("<b>#{@annex_lbl} #{num}</b>")
257
257
  end
258
258
 
259
- def section_naming(c, num, lvl, i)
260
- if c["guidance"] then section_names1(c, "#{num}E", lvl + 1)
261
- elsif c.parent["container"] then
262
- i+= 1
263
- section_names1(c, i, lvl)
264
- else
265
- i+= 1
266
- section_names1(c, "#{num}.#{i}", lvl + 1)
259
+ def clause_names(docxml, sect_num)
260
+ q = "//clause[parent::sections]"
261
+ @topnum = nil
262
+ lvl = 0
263
+ docxml.xpath(ns(q)).each do |c|
264
+ container_names(c, 0)
265
+ sect_num, lvl = sect_names(c, nil, sect_num, 0, lvl)
267
266
  end
268
- i
269
267
  end
270
268
 
271
- def section_names(clause, num, lvl)
272
- return num if clause.nil?
273
- num = num + 1
274
- @topnum = num unless clause["container"]
275
- @anchors[clause["id"]] = clause["container"] ?
276
- { label: nil, xref: clause.at(ns("./title"))&.text, level: 1 } :
277
- { label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
278
- i = 0
279
- i = @topnum if clause.parent["container"] && !clause["container"]
280
- if clause.parent["container"] && !clause["container"]
269
+ def container_names(clause, lvl)
270
+ if clause["container"]
271
+ @anchors[clause["id"]] =
272
+ { label: nil, xref: clause.at(ns("./title"))&.text, level: lvl+1 }
281
273
  end
282
274
  clause.xpath(ns("./clause | ./term | ./terms | "\
283
275
  "./definitions")).each do |c|
284
- i = section_naming(c, num, lvl, i)
276
+ container_names(c, clause["container"] ? lvl+1 : lvl)
285
277
  end
286
- num
287
278
  end
288
279
 
289
- def section_names1(clause, num, lvl)
290
- if clause.parent["container"] && !clause["container"]
291
- newsect = true
292
- if @topnum > 1
293
- num = @topnum + 1
294
- end
280
+ def sect_names(clause, num, i, lvl, prev_lvl)
281
+ return i if clause.nil?
282
+ curr = i
283
+ if clause["container"]
284
+ retlvl = lvl+1
285
+ else
286
+ retlvl = lvl
287
+ i+=1
288
+ curr = i
289
+ name = num.nil? ? i.to_s : "#{num}.#{i}"
290
+ @anchors[clause["id"]] = { label: name, xref: l10n("#{@clause_lbl} #{name}"), level: lvl+1 }
295
291
  end
296
- @anchors[clause["id"]] = clause["container"] ?
297
- { label: nil, xref: clause.at(ns("./title")), level: clause.ancestors("clause[@container]").length + 1 } :
298
- { label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
299
- i = 0
300
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).
301
- each do |c|
302
- i = section_naming(c, num, lvl, i)
292
+ prev = lvl
293
+ j = 0
294
+ clause.xpath(ns("./clause | ./term | ./terms | "\
295
+ "./definitions")).each do |c|
296
+ if clause["container"]
297
+ i, lvl = sect_names(c, num, i, lvl, lvl)
298
+ else
299
+ j, prev = sect_names(c, name, j, lvl+1, prev)
300
+ end
303
301
  end
304
- @topnum = num if newsect
302
+ i = j if j >0
303
+ i = curr if lvl < prev
304
+ [i, prev]
305
305
  end
306
306
 
307
307
  def annex_naming(c, num, lvl, i)
@@ -80,7 +80,7 @@ module IsoDoc
80
80
  h1 = to_xhtml_fragment(h.dup)
81
81
  h1.traverse do |x|
82
82
  x.replace(" ") if x.name == "span" &&
83
- /mso-tab-count/.match?(x["style"])
83
+ /mso-tab-count/.match(x["style"])
84
84
  x.remove if x.name == "span" && x["class"] == "MsoCommentReference"
85
85
  x.remove if x.name == "a" && x["epub:type"] == "footnote"
86
86
  x.replace(x.children) if x.name == "a"
@@ -191,10 +191,6 @@ module IsoDoc
191
191
  end
192
192
 
193
193
  def initial_anchor_names(d)
194
- #preface_names(d.at(ns("//foreword")))
195
- #preface_names(d.at(ns("//introduction")))
196
- #preface_names(d.at(ns("//preface/terms | "\
197
- #"//preface/clause[descendant::terms]")))
198
194
  d.xpath(ns(FRONT_CLAUSE)).each do |c|
199
195
  preface_names(c)
200
196
  sequential_asset_names(c)
@@ -241,52 +237,52 @@ module IsoDoc
241
237
  l10n("<b>#{@annex_lbl} #{num}</b>")
242
238
  end
243
239
 
244
- def section_naming(c, num, lvl, i)
245
- if c["guidance"] then section_names1(c, "#{num}E", lvl + 1)
246
- elsif c.parent["container"] then
247
- i+= 1
248
- section_names1(c, i, lvl)
249
- else
250
- i+= 1
251
- section_names1(c, "#{num}.#{i}", lvl + 1)
240
+ def clause_names(docxml, sect_num)
241
+ q = "//clause[parent::sections]"
242
+ @topnum = nil
243
+ lvl = 0
244
+ docxml.xpath(ns(q)).each do |c|
245
+ container_names(c, 0)
246
+ sect_num, lvl = sect_names(c, nil, sect_num, 0, lvl)
252
247
  end
253
- i
254
248
  end
255
249
 
256
- def section_names(clause, num, lvl)
257
- return num if clause.nil?
258
- num = num + 1
259
- @topnum = num unless clause["container"]
260
- @anchors[clause["id"]] = clause["container"] ?
261
- { label: nil, xref: clause.at(ns("./title"))&.text, level: 1 } :
262
- { label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
263
- i = 0
264
- i = @topnum if clause.parent["container"] && !clause["container"]
265
- if clause.parent["container"] && !clause["container"]
250
+ def container_names(clause, lvl)
251
+ if clause["container"]
252
+ @anchors[clause["id"]] =
253
+ { label: nil, xref: clause.at(ns("./title"))&.text, level: lvl+1 }
266
254
  end
267
255
  clause.xpath(ns("./clause | ./term | ./terms | "\
268
256
  "./definitions")).each do |c|
269
- i = section_naming(c, num, lvl, i)
257
+ container_names(c, clause["container"] ? lvl+1 : lvl)
270
258
  end
271
- num
272
259
  end
273
260
 
274
- def section_names1(clause, num, lvl)
275
- if clause.parent["container"] && !clause["container"]
276
- newsect = true
277
- if @topnum > 1
278
- num = @topnum + 1
279
- end
261
+ def sect_names(clause, num, i, lvl, prev_lvl)
262
+ return i if clause.nil?
263
+ curr = i
264
+ if clause["container"]
265
+ retlvl = lvl+1
266
+ else
267
+ retlvl = lvl
268
+ i+=1
269
+ curr = i
270
+ name = num.nil? ? i.to_s : "#{num}.#{i}"
271
+ @anchors[clause["id"]] = { label: name, xref: l10n("#{@clause_lbl} #{name}"), level: lvl+1 }
280
272
  end
281
- @anchors[clause["id"]] = clause["container"] ?
282
- { label: nil, xref: clause.at(ns("./title")), level: clause.ancestors("clause[@container]").length + 1 } :
283
- { label: num.to_s, xref: l10n("#{@clause_lbl} #{num}"), level: lvl }
284
- i = 0
285
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).
286
- each do |c|
287
- i = section_naming(c, num, lvl, i)
273
+ prev = lvl
274
+ j = 0
275
+ clause.xpath(ns("./clause | ./term | ./terms | "\
276
+ "./definitions")).each do |c|
277
+ if clause["container"]
278
+ i, lvl = sect_names(c, num, i, lvl, lvl)
279
+ else
280
+ j, prev = sect_names(c, name, j, lvl+1, prev)
281
+ end
288
282
  end
289
- @topnum = num if newsect
283
+ i = j if j >0
284
+ i = curr if lvl < prev
285
+ [i, prev]
290
286
  end
291
287
 
292
288
  def annex_naming(c, num, lvl, i)
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "asciidoctor", "~> 1.5.7"
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
30
  spec.add_dependency "nokogiri"
31
- spec.add_dependency "asciidoctor-iso", "~> 0.9.6"
31
+ spec.add_dependency "asciidoctor-iso", "~> 0.10.1"
32
32
  spec.add_dependency "isodoc", ">= 0.8.4"
33
33
  spec.add_dependency "twitter_cldr"
34
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-mpdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.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: 2018-08-06 00:00:00.000000000 Z
11
+ date: 2018-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.6
61
+ version: 0.10.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.6
68
+ version: 0.10.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: isodoc
71
71
  requirement: !ruby/object:Gem::Requirement