prawn-markup 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -41
- data/lib/prawn/markup/builders/list_builder.rb +2 -1
- data/lib/prawn/markup/builders/nestable_builder.rb +5 -3
- data/lib/prawn/markup/processor.rb +5 -1
- data/lib/prawn/markup/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3224b605102e828f529ef5acdd6ba99910237a58e7a609a631c670b1bb025559
|
4
|
+
data.tar.gz: fc939e927be4748051a2ab4d9f0b8c4155aacd1234c3c7dc41eb1e9861d5533c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5099a48640adb9c06a706cd63bf70767365f74361e1c80dc0501fda5c0e23999d6d7ff1264edfe8aaf45aa05af06dfb285d8d9324f8e6a750b9817184c676dcc
|
7
|
+
data.tar.gz: b6725ba940801a114a41d3645605406f947c4f6dcb0e35bc7901ee12cc10241591aee889bfae956ab11f26e7a835e45aa5a18395f712748b4cd0d08e14b7c838
|
data/README.md
CHANGED
@@ -37,12 +37,12 @@ doc.markup('<p>Hello World</p><hr/><p>KTHXBYE</p>')
|
|
37
37
|
|
38
38
|
This gem parses the given HTML and layouts the following elements in a vertical order:
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
- Text blocks: `p`, `div`, `ol`, `ul`, `li`, `hr`, `br`
|
41
|
+
- Text semantics: `a`, `b`, `strong`, `i`, `em`, `u`, `s`, `del`, `sub`, `sup`, `color`
|
42
|
+
- Headings: `h1`, `h2`, `h3`, `h4`, `h5`, `h6`
|
43
|
+
- Tables: `table`, `tr`, `td`, `th`
|
44
|
+
- Media: `img`, `iframe`
|
45
|
+
- Inputs: `type=checkbox`, `type=radio`
|
46
46
|
|
47
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
|
|
@@ -75,40 +75,40 @@ Tables and lists are rendered with [prawn-table](https://github.com/prawnpdf/pra
|
|
75
75
|
|
76
76
|
Beside these options handled by Prawn / prawn-table, the following values may be customized:
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
78
|
+
- `:text`
|
79
|
+
- `:preprocessor`: A proc/callable that is called each time before a chunk of text is rendered.
|
80
|
+
- `:margin_bottom`: Margin after each `<p>`, `<ol>`, `<ul>` or `<table>`. Defaults to about half a line.
|
81
|
+
- `:heading1-6`
|
82
|
+
- `:margin_top`: Margin before a heading. Default is 0.
|
83
|
+
- `:margin_bottom`: Margin after a heading. Default is 0.
|
84
|
+
- `:table`
|
85
|
+
- `:placeholder`
|
86
|
+
- `:too_large`: If the table content does not fit into the current bounding box, this text/callable is rendered instead. Defaults to '[table content too large]'.
|
87
|
+
- `:subtable_too_large`: If the content of a subtable cannot be fitted into the table, this text is rendered instead. Defaults to '[nested tables with automatic width are not supported]'.
|
88
|
+
- `:list`
|
89
|
+
- `:vertical_margin`: Margin at the top and the bottom of a list. Default is 5.
|
90
|
+
- `:bullet`
|
91
|
+
- `:char`: The text used as bullet in unordered lists. Default is '•'.
|
92
|
+
- `:margin`: Margin before the bullet. Default is 10.
|
93
|
+
- `:content`
|
94
|
+
- `:margin`: Margin between the bullet and the content. Default is 10.
|
95
|
+
- `:placeholder`
|
96
|
+
- `:too_large`: If the list content does not fit into the current bounding box, this text/callable is rendered instead. Defaults to '[list content too large]'.
|
97
|
+
- `:image`
|
98
|
+
- `:loader`: A callable that accepts the `src` attribute as an argument an returns a value understood by Prawn's `image` method. Loads `http(s)` URLs and base64 encoded data URIs by default.
|
99
|
+
- `:placeholder`: If an image is not supported, this text/callable is rendered instead. Defaults to '[unsupported image]'.
|
100
|
+
- `:iframe`
|
101
|
+
- `:placeholder`: If the HTML contains IFrames, this text/callable is rendered instead.
|
102
|
+
A callable gets the URL of the IFrame as an argument. Defaults to ignore iframes.
|
103
|
+
- `:input`
|
104
|
+
- `:symbol_font`: A special font to print checkboxes and radios. Prawn's standard fonts do not support special unicode characters. Do not forget to update the document's `font_families`.
|
105
|
+
- `:symbol_font_size`: The size of the special font to print checkboxes and radios.
|
106
|
+
- `:checkbox`
|
107
|
+
- `:checked`: The char to print for a checked checkbox. Default is '☑'.
|
108
|
+
- `:unchecked`: The char to print for an unchecked checkbox. Default is '☐'.
|
109
|
+
- `:radio`
|
110
|
+
- `:checked`: The char to print for a checked radio. Default is '◉'.
|
111
|
+
- `:unchecked`: The char to print for an unchecked radio. Default is '○'.
|
112
112
|
|
113
113
|
## Development
|
114
114
|
|
@@ -128,4 +128,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
128
128
|
|
129
129
|
## Code of Conduct
|
130
130
|
|
131
|
-
Everyone interacting in the Prawn::Markup project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/puzzle/prawn-markup/blob/
|
131
|
+
Everyone interacting in the Prawn::Markup project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/puzzle/prawn-markup/blob/main/CODE_OF_CONDUCT.md).
|
@@ -110,9 +110,10 @@ module Prawn
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def bullet_text_width
|
113
|
+
largest_string = bullet('0' * list.items.size.digits.size)
|
113
114
|
font = bullet_font
|
115
|
+
encoded = font.normalize_encoding(largest_string)
|
114
116
|
font_size = column_cell_style(:bullet)[:size] || pdf.font_size
|
115
|
-
encoded = font.normalize_encoding(bullet(list.items.size))
|
116
117
|
font.compute_width_of(encoded, size: font_size)
|
117
118
|
end
|
118
119
|
|
@@ -34,10 +34,12 @@ module Prawn
|
|
34
34
|
hash.dup.tap do |image_hash|
|
35
35
|
image_hash.delete(:width)
|
36
36
|
image_hash[:image_width] = SizeConverter.new(max_width).parse(hash[:width])
|
37
|
-
|
38
|
-
|
39
|
-
image_hash[:fit] = [max_width, 999_999]
|
37
|
+
natural_width, _height = natural_image_dimensions(image_hash)
|
38
|
+
if max_width && (max_width < natural_width)
|
39
|
+
image_hash[:fit] = [max_width, 999_999]
|
40
40
|
end
|
41
|
+
rescue Prawn::Errors::UnsupportedImageType
|
42
|
+
image_hash.clear
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -125,7 +125,11 @@ module Prawn
|
|
125
125
|
def style_properties
|
126
126
|
style = current_attrs['style']
|
127
127
|
if style
|
128
|
-
style
|
128
|
+
style
|
129
|
+
.split(';')
|
130
|
+
.map { |p| p.split(':', 2).map(&:strip) }
|
131
|
+
.select { |tuple| tuple.size == 2 }
|
132
|
+
.to_h
|
129
133
|
else
|
130
134
|
{}
|
131
135
|
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.7
|
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-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.
|
205
|
+
rubygems_version: 3.3.19
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Parse simple HTML markup to include in Prawn PDFs
|