prawn-markup 0.3.4 → 0.3.5

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: a5217761bc64b6cf5ae6697d326934a9b87d3e54a3a65428f9c7025d3a03f043
4
- data.tar.gz: c3274d3dfd6ab699f4d9fe17db8148305c9b4c4c7da8cd3b2a8b834735380583
3
+ metadata.gz: c3e26315f0588069e152aea5344bb9e79523b71aed0a574875036802ccb3a3d0
4
+ data.tar.gz: 1c9f31e0e3d19c4bc0c9811d1c0043512a11fa5ca9b15e864919c3ab4d633402
5
5
  SHA512:
6
- metadata.gz: 728da10a3ce7d80aca95a3b9d54d9122c9c791567ab150188c6f459bb0de15863524322d091ed01900e844661aa0e5337542fd191f03eb97d080e27b905cc394
7
- data.tar.gz: c701c14bcc7fd0baa8cb17179f5096caef7a8f8ce829f8d548d9667d5ce78f2ec2248a1848eca32e01cb0e52e94befb0a845a9d6da0f14c851fb195420e9c90f
6
+ metadata.gz: 4251fb1e5ea67b00c9e8281712f3bfe6a866c5ec2054c972de9be13d56939c3342e3cebc23a0cbe3164aa93b2fd6a59fa85de83487a8690413ebaad747b16ff1
7
+ data.tar.gz: b9900e07d2636efe47842bf2ca9b8a6445cdfe3cee1d9fb92149f9c7e6c80956081cf4bebce79be9245a7c7968892abbe6563af8df5b5ff762bfdb4fb680d4d4
data/README.md CHANGED
@@ -38,13 +38,13 @@ doc.markup('<p>Hello World</p><hr/><p>KTHXBYE</p>')
38
38
  This gem parses the given HTML and layouts the following elements in a vertical order:
39
39
 
40
40
  * Text blocks: `p`, `div`, `ol`, `ul`, `li`, `hr`, `br`
41
- * Text semantics: `a`, `b`, `strong`, `i`, `em`, `u`, `s`, `del`, `sub`, `sup`
41
+ * Text semantics: `a`, `b`, `strong`, `i`, `em`, `u`, `s`, `del`, `sub`, `sup`, `color`
42
42
  * Headings: `h1`, `h2`, `h3`, `h4`, `h5`, `h6`
43
43
  * Tables: `table`, `tr`, `td`, `th`
44
44
  * Media: `img`, `iframe`
45
45
  * Inputs: `type=checkbox`, `type=radio`
46
46
 
47
- All other elements are ignored, their content is added to the parent element. With a few exceptions, no CSS is processed. One exception is the `width` property of `img`, `td` and `th`, which may contain values in `cm`, `mm`, `px`, `pt`, `%` or `auto`.
47
+ All other elements are ignored, their content is added to the parent element. With a few exceptions, no CSS is processed. One exception is the `width` property of `img`, `td` and `th`, which may contain values in `cm`, `mm`, `px`, `pt`, `%` or `auto`. Another exception is the `rgb` or `cmyk` properties of the Prawn-specific `color` tag.
48
48
 
49
49
  If no explicit loader is given (see above), images are loaded from `http(s)` addresses or may be contained in the `src` attribute as base64 encoded data URIs. Prawn only supports `PNG` and `JPG`.
50
50
 
@@ -98,7 +98,7 @@ module Prawn
98
98
  end
99
99
 
100
100
  def content_width
101
- column_widths.last && column_widths.last - content_margin
101
+ column_widths.last && (column_widths.last - content_margin)
102
102
  end
103
103
 
104
104
  def compute_column_widths
@@ -131,7 +131,7 @@ module Prawn
131
131
 
132
132
  def normalize_cell_hash(node, width, style_options)
133
133
  if width.nil? && total_width
134
- width = total_width - column_width_sum - (columns_without_width - 1) * MIN_COL_WIDTH
134
+ width = total_width - column_width_sum - ((columns_without_width - 1) * MIN_COL_WIDTH)
135
135
  end
136
136
  super(node, width, style_options)
137
137
  end
@@ -190,13 +190,13 @@ module Prawn
190
190
 
191
191
  def increase_widths(sum)
192
192
  diff = total_width - sum
193
- column_widths.map! { |w| w + w / sum * diff }
193
+ column_widths.map! { |w| w + (w / sum * diff) }
194
194
  end
195
195
 
196
196
  def decrease_widths(sum)
197
197
  sum += columns_without_width * MIN_COL_WIDTH
198
198
  diff = sum - total_width
199
- column_widths.map! { |w| w ? [w - w / sum * diff, 0].max : nil }
199
+ column_widths.map! { |w| w ? [w - (w / sum * diff), 0].max : nil }
200
200
  end
201
201
 
202
202
  def failover_on_error
@@ -210,7 +210,7 @@ module Prawn
210
210
 
211
211
  def horizontal_padding
212
212
  @horizontal_padding ||= begin
213
- padding = table_options[:cell][:padding] || [DEFAULT_CELL_PADDING] * 4
213
+ padding = table_options[:cell][:padding] || ([DEFAULT_CELL_PADDING] * 4)
214
214
  padding.is_a?(Array) ? padding[1] + padding[3] : padding
215
215
  end
216
216
  end
@@ -57,7 +57,7 @@ module Prawn
57
57
  def default_options_with_size(level)
58
58
  default = text_options.dup
59
59
  default[:size] ||= pdf.font_size
60
- default[:size] *= 2.5 - level * 0.25
60
+ default[:size] *= 2.5 - (level * 0.25)
61
61
  HashMerger.deep(default, options[:"heading#{level}"] || {})
62
62
  end
63
63
 
@@ -90,9 +90,12 @@ module Prawn
90
90
  end
91
91
 
92
92
  def add_cell_image(cell)
93
+ src = current_attrs['src']
94
+ return if src.to_s.strip.empty?
95
+
93
96
  add_cell_text_node(cell)
94
- img = image_properties(current_attrs['src'])
95
- cell.nodes << img || invalid_image_placeholder
97
+ img = image_properties(src)
98
+ (cell.nodes << img) || invalid_image_placeholder
96
99
  end
97
100
 
98
101
  def add_table(cells)
@@ -6,7 +6,7 @@ module Prawn
6
6
  def self.prepended(base)
7
7
  base.known_elements.push(
8
8
  'a', 'b', 'strong', 'i', 'em', 'u', 'strikethrough', 'strike', 's', 'del',
9
- 'sub', 'sup'
9
+ 'sub', 'sup', 'color'
10
10
  )
11
11
  end
12
12
 
@@ -78,6 +78,19 @@ module Prawn
78
78
  append_text('</sup>')
79
79
  end
80
80
 
81
+ def start_color
82
+ rgb, c, m, y, k = current_attrs.values_at('rgb', 'c', 'm', 'y', 'k')
83
+
84
+ if [c, m, y, k].all?
85
+ append_text("<color c=\"#{c}\" m=\"#{m}\" y=\"#{y}\" k=\"#{k}\">")
86
+ else
87
+ append_text("<color rgb=\"#{rgb}\">")
88
+ end
89
+ end
90
+
91
+ def end_color
92
+ append_text('</color>')
93
+ end
81
94
  end
82
95
  end
83
96
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module Markup
5
- VERSION = '0.3.4'
5
+ VERSION = '0.3.5'
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.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Zumkehr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri