prawn-markup 0.3.0 → 0.3.1

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: 3e42ddd575822d3805d7edb1525124617db37098e35ad139a2fed48824d08790
4
- data.tar.gz: feb4ae593f40ebb09875ff2e4e9158ee4de7856980cf90e602103855d9bb47ad
3
+ metadata.gz: fcd47aaef564239231b4546e4122f9f15625c15de5aa3d91bf0e3933e62d46ce
4
+ data.tar.gz: 77d0fa0b0b8261d6e3c0a8b7df75f797b31914c761c32dc229ba93edf269a587
5
5
  SHA512:
6
- metadata.gz: c13137a43fb81062dd27fcc0492d9d910f7244bf8841cda87c690bc36ad8a17434e783a864874e56cdeea90e7a4eff49b242c9f62d72a318a869110d2a393848
7
- data.tar.gz: f43d2499d55744f2e973a11ea9add7c254b283eee5639d29aa043f2b600d40a00fc52b4087c7bf7012d9eba502d9ab36a4da6b5f10484bdc9eb91e703dd1a23f
6
+ metadata.gz: 395187b2fe33613d41bb9f4ac89f9b370cff0ac2a01212c96d5c88eea57e88a255e93a44e519f723b0955b468eb4896da06b7094ba3aa046302ab6733f3b8e6a
7
+ data.tar.gz: fd2c752f5eb61d1029371a4d2cd2476168476696d464853ba288ca263b6a8c903cb367a8f29dbc104f8e2d809b1f7cca02c779e863e9bd10385849be283d51db
@@ -39,6 +39,7 @@ module Prawn
39
39
  prepend Prawn::Markup::Processor::Lists
40
40
 
41
41
  def initialize(pdf, options = {})
42
+ super()
42
43
  @pdf = pdf
43
44
  @options = options
44
45
  end
@@ -52,10 +53,8 @@ module Prawn
52
53
  end
53
54
 
54
55
  def start_element(name, attrs = [])
55
- stack.push(name: name, attrs: Hash[attrs])
56
- if self.class.known_elements.include?(name)
57
- send("start_#{name}") if respond_to?("start_#{name}", true)
58
- end
56
+ stack.push(name: name, attrs: attrs.to_h)
57
+ send("start_#{name}") if known_element?(name) && respond_to?("start_#{name}", true)
59
58
  end
60
59
 
61
60
  def end_element(name)
@@ -69,11 +68,11 @@ module Prawn
69
68
  end
70
69
 
71
70
  def error(string)
72
- logger.info('SAX parsing error: ' + string.strip) if logger
71
+ logger.info("SAX parsing error: #{string.strip}") if logger
73
72
  end
74
73
 
75
74
  def warning(string)
76
- logger.info('SAX parsing warning: ' + string.strip) if logger
75
+ logger.info("SAX parsing warning: #{string.strip}") if logger
77
76
  end
78
77
 
79
78
  private
@@ -85,6 +84,10 @@ module Prawn
85
84
  @text_buffer = +''
86
85
  end
87
86
 
87
+ def known_element?(name)
88
+ self.class.known_elements.include?(name)
89
+ end
90
+
88
91
  def append_text(string)
89
92
  text_buffer.concat(string)
90
93
  end
@@ -122,8 +125,7 @@ module Prawn
122
125
  def style_properties
123
126
  style = current_attrs['style']
124
127
  if style
125
- tokens = style.split(';').map { |p| p.split(':', 2).map(&:strip) }
126
- Hash[tokens]
128
+ style.split(';').map { |p| p.split(':', 2).map(&:strip) }.to_h
127
129
  else
128
130
  {}
129
131
  end
@@ -67,7 +67,9 @@ module Prawn
67
67
  end
68
68
 
69
69
  def current_list_item
70
- current_list.items.last
70
+ items = current_list.items
71
+ items << Elements::Item.new if items.empty?
72
+ items.last
71
73
  end
72
74
 
73
75
  def inside_container?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module Markup
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Zumkehr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-26 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri