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 +4 -4
- data/README.md +2 -2
- data/lib/prawn/markup/builders/list_builder.rb +1 -1
- data/lib/prawn/markup/builders/table_builder.rb +4 -4
- data/lib/prawn/markup/processor/headings.rb +1 -1
- data/lib/prawn/markup/processor/tables.rb +5 -2
- data/lib/prawn/markup/processor/text.rb +14 -1
- data/lib/prawn/markup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3e26315f0588069e152aea5344bb9e79523b71aed0a574875036802ccb3a3d0
|
4
|
+
data.tar.gz: 1c9f31e0e3d19c4bc0c9811d1c0043512a11fa5ca9b15e864919c3ab4d633402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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(
|
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
|
data/lib/prawn/markup/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2022-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|