prawn-markup 0.2.1 → 0.2.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 +4 -4
- data/.rubocop.yml +18 -18
- data/.travis.yml +1 -7
- data/Gemfile.lock +18 -18
- data/README.md +5 -2
- data/lib/prawn/markup/builders/list_builder.rb +4 -1
- data/lib/prawn/markup/builders/nestable_builder.rb +6 -4
- data/lib/prawn/markup/builders/table_builder.rb +4 -6
- data/lib/prawn/markup/processor/blocks.rb +11 -5
- data/lib/prawn/markup/processor/lists.rb +7 -2
- data/lib/prawn/markup/processor/tables.rb +11 -2
- data/lib/prawn/markup/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2a68c2f0773fd3769437fcee6aed0cba929e95808c6618b8e36dc2f7624c8fe
|
|
4
|
+
data.tar.gz: d379eb9ed4e28cbdbeca6048b06019d5dd4d8e741cb41ebd304a65a3a05be034
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0da58a2bcd5b700753ae0f59f0c68c4014af194c74d2946e61e5028e29e8263fba91b255b023f2e9db5246a44a05cf5798b6808831309936091c7cdf53ff6c8f
|
|
7
|
+
data.tar.gz: 9129eaba7c308464c68c501dab041e2e54f79618734b0fd29c53554320b12cb6b2c18c25aa02bd77108eb3c17728720f95dce3412a4664f5fcc1d9c37beefccf
|
data/.rubocop.yml
CHANGED
|
@@ -15,10 +15,6 @@ Metrics/ClassLength:
|
|
|
15
15
|
Metrics/CyclomaticComplexity:
|
|
16
16
|
Severity: error
|
|
17
17
|
|
|
18
|
-
Metrics/LineLength:
|
|
19
|
-
Max: 100
|
|
20
|
-
Severity: error
|
|
21
|
-
|
|
22
18
|
Metrics/MethodLength:
|
|
23
19
|
Max: 10
|
|
24
20
|
Severity: error
|
|
@@ -31,32 +27,36 @@ Metrics/ParameterLists:
|
|
|
31
27
|
Max: 4
|
|
32
28
|
Severity: warning
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
Layout/LineLength:
|
|
31
|
+
Max: 100
|
|
32
|
+
Severity: error
|
|
33
|
+
|
|
34
|
+
# We thinks that's fine for specs
|
|
35
|
+
Layout/EmptyLinesAroundBlockBody:
|
|
36
36
|
Enabled: false
|
|
37
37
|
|
|
38
|
-
#
|
|
39
|
-
|
|
38
|
+
# We thinks that's fine
|
|
39
|
+
Layout/EmptyLinesAroundClassBody:
|
|
40
40
|
Enabled: false
|
|
41
41
|
|
|
42
|
-
#
|
|
43
|
-
|
|
42
|
+
# We thinks that's fine
|
|
43
|
+
Layout/EmptyLinesAroundModuleBody:
|
|
44
44
|
Enabled: false
|
|
45
45
|
|
|
46
|
-
# Keep
|
|
47
|
-
|
|
46
|
+
# Keep for now, easier with superclass definitions
|
|
47
|
+
Style/ClassAndModuleChildren:
|
|
48
48
|
Enabled: false
|
|
49
49
|
|
|
50
|
-
#
|
|
51
|
-
|
|
50
|
+
# The ones we use must exist for the entire class hierarchy.
|
|
51
|
+
Style/ClassVars:
|
|
52
52
|
Enabled: false
|
|
53
53
|
|
|
54
|
-
#
|
|
55
|
-
|
|
54
|
+
# Well, well, well
|
|
55
|
+
Style/Documentation:
|
|
56
56
|
Enabled: false
|
|
57
57
|
|
|
58
|
-
#
|
|
59
|
-
|
|
58
|
+
# Keep single line bodys for if and unless
|
|
59
|
+
Style/IfUnlessModifier:
|
|
60
60
|
Enabled: false
|
|
61
61
|
|
|
62
62
|
# We think that's the developers choice
|
data/.travis.yml
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
|
|
3
1
|
language: ruby
|
|
4
2
|
|
|
5
3
|
rvm:
|
|
6
|
-
- 2.5.
|
|
4
|
+
- 2.5.7
|
|
7
5
|
|
|
8
6
|
env:
|
|
9
7
|
global:
|
|
10
8
|
- CC_TEST_REPORTER_ID=d70fe39ffb8f2f7c5f837f0133d10a3a1c6784d0dd189153111577b60f74c603
|
|
11
9
|
|
|
12
|
-
before_install:
|
|
13
|
-
- gem update --system
|
|
14
|
-
- gem install bundler
|
|
15
|
-
|
|
16
10
|
before_script:
|
|
17
11
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
18
12
|
- chmod +x ./cc-test-reporter
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
prawn-markup (0.2.
|
|
4
|
+
prawn-markup (0.2.2)
|
|
5
5
|
nokogiri
|
|
6
6
|
prawn
|
|
7
7
|
prawn-table
|
|
@@ -12,17 +12,16 @@ GEM
|
|
|
12
12
|
Ascii85 (1.0.3)
|
|
13
13
|
afm (0.2.2)
|
|
14
14
|
ast (2.4.0)
|
|
15
|
-
byebug (11.
|
|
15
|
+
byebug (11.1.1)
|
|
16
16
|
diff-lcs (1.3)
|
|
17
17
|
docile (1.3.2)
|
|
18
18
|
hashery (2.1.2)
|
|
19
19
|
jaro_winkler (1.5.4)
|
|
20
|
-
json (2.2.0)
|
|
21
20
|
mini_portile2 (2.4.0)
|
|
22
|
-
nokogiri (1.10.
|
|
21
|
+
nokogiri (1.10.9)
|
|
23
22
|
mini_portile2 (~> 2.4.0)
|
|
24
23
|
parallel (1.19.1)
|
|
25
|
-
parser (2.
|
|
24
|
+
parser (2.7.0.4)
|
|
26
25
|
ast (~> 2.4.0)
|
|
27
26
|
pdf-core (0.7.0)
|
|
28
27
|
pdf-inspector (1.3.0)
|
|
@@ -40,35 +39,36 @@ GEM
|
|
|
40
39
|
prawn (>= 1.3.0, < 3.0.0)
|
|
41
40
|
rainbow (3.0.0)
|
|
42
41
|
rake (13.0.1)
|
|
42
|
+
rexml (3.2.4)
|
|
43
43
|
rspec (3.9.0)
|
|
44
44
|
rspec-core (~> 3.9.0)
|
|
45
45
|
rspec-expectations (~> 3.9.0)
|
|
46
46
|
rspec-mocks (~> 3.9.0)
|
|
47
|
-
rspec-core (3.9.
|
|
48
|
-
rspec-support (~> 3.9.
|
|
49
|
-
rspec-expectations (3.9.
|
|
47
|
+
rspec-core (3.9.1)
|
|
48
|
+
rspec-support (~> 3.9.1)
|
|
49
|
+
rspec-expectations (3.9.1)
|
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
51
|
rspec-support (~> 3.9.0)
|
|
52
|
-
rspec-mocks (3.9.
|
|
52
|
+
rspec-mocks (3.9.1)
|
|
53
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
54
|
rspec-support (~> 3.9.0)
|
|
55
|
-
rspec-support (3.9.
|
|
56
|
-
rubocop (0.
|
|
55
|
+
rspec-support (3.9.2)
|
|
56
|
+
rubocop (0.80.1)
|
|
57
57
|
jaro_winkler (~> 1.5.1)
|
|
58
58
|
parallel (~> 1.10)
|
|
59
|
-
parser (>= 2.
|
|
59
|
+
parser (>= 2.7.0.1)
|
|
60
60
|
rainbow (>= 2.2.2, < 4.0)
|
|
61
|
+
rexml
|
|
61
62
|
ruby-progressbar (~> 1.7)
|
|
62
63
|
unicode-display_width (>= 1.4.0, < 1.7)
|
|
63
64
|
ruby-progressbar (1.10.1)
|
|
64
65
|
ruby-rc4 (0.1.5)
|
|
65
|
-
simplecov (0.
|
|
66
|
+
simplecov (0.18.5)
|
|
66
67
|
docile (~> 1.1)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
unicode-display_width (1.6.0)
|
|
68
|
+
simplecov-html (~> 0.11)
|
|
69
|
+
simplecov-html (0.12.2)
|
|
70
|
+
ttfunk (1.6.2.1)
|
|
71
|
+
unicode-display_width (1.6.1)
|
|
72
72
|
|
|
73
73
|
PLATFORMS
|
|
74
74
|
ruby
|
data/README.md
CHANGED
|
@@ -46,9 +46,9 @@ doc.markup_options = {
|
|
|
46
46
|
doc.markup('<p>Hello World</p><hr/><p>KTHXBYE</p>', text: { align: :center })
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Options may be set for `text`, `table` (`cell` and `header`) and `list` (`content` and `bullet`).
|
|
49
|
+
Options may be set for `text`, `heading[1-6]`, `table` (subkeys `cell` and `header`) and `list` (subkeys `content` and `bullet`).
|
|
50
50
|
|
|
51
|
-
Text options include all keys from Prawns [#text](http://prawnpdf.org/api-docs/2.0/Prawn/Text.html#text-instance_method) method: `font`, `size`, `color`, `style`, `align`, `valign`, `leading`,`direction`, `character_spacing`, `indent_paragraphs`, `kerning`, `mode`.
|
|
51
|
+
Text and heading options include all keys from Prawns [#text](http://prawnpdf.org/api-docs/2.0/Prawn/Text.html#text-instance_method) method: `font`, `size`, `color`, `style`, `align`, `valign`, `leading`,`direction`, `character_spacing`, `indent_paragraphs`, `kerning`, `mode`.
|
|
52
52
|
|
|
53
53
|
Tables and lists are rendered with [prawn-table](https://github.com/prawnpdf/prawn-table) and have the following additional options: `padding`, `borders`, `border_width`, `border_color`, `background_color`, `border_lines`, `rotate`, `overflow`, `min_font_size`. Options from `text` may be overridden.
|
|
54
54
|
|
|
@@ -84,6 +84,9 @@ All other elements are ignored, their content is added to the parent element. Wi
|
|
|
84
84
|
|
|
85
85
|
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`.
|
|
86
86
|
|
|
87
|
+
## Example
|
|
88
|
+
|
|
89
|
+
Have a look at [showcase.html](spec/fixtures/showcase.html), which is rendered by the corresponding [spec](spec/prawn/markup/showcase_spec.rb). Uncomment the `lookatit` call there to directly open the generated PDF when running the spec with `spec spec/prawn/markup/showcase_spec.rb`.
|
|
87
90
|
|
|
88
91
|
## Development
|
|
89
92
|
|
|
@@ -49,10 +49,12 @@ module Prawn
|
|
|
49
49
|
def extract_text_cell_style(hash)
|
|
50
50
|
TEXT_STYLE_OPTIONS
|
|
51
51
|
.each_with_object({}) { |key, h| h[key] = hash[key] }
|
|
52
|
-
.tap
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
.tap { |options| convert_style_options(options) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def convert_style_options(hash)
|
|
56
|
+
hash[:font_style] ||= hash.delete(:style)
|
|
57
|
+
hash[:text_color] ||= hash.delete(:color)
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
def type_key(object)
|
|
@@ -22,7 +22,10 @@ module Prawn
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def draw
|
|
25
|
-
|
|
25
|
+
# fix https://github.com/prawnpdf/prawn-table/issues/120
|
|
26
|
+
pdf.font_size(table_options[:cell][:size] || pdf.font_size) do
|
|
27
|
+
make.draw
|
|
28
|
+
end
|
|
26
29
|
rescue Prawn::Errors::CannotFit => e
|
|
27
30
|
if failover_on_error
|
|
28
31
|
draw
|
|
@@ -233,11 +236,6 @@ module Prawn
|
|
|
233
236
|
convert_style_options(opts[:header])
|
|
234
237
|
end
|
|
235
238
|
|
|
236
|
-
def convert_style_options(hash)
|
|
237
|
-
hash[:font_style] ||= hash.delete(:style)
|
|
238
|
-
hash[:text_color] ||= hash.delete(:color)
|
|
239
|
-
end
|
|
240
|
-
|
|
241
239
|
def default_table_options
|
|
242
240
|
{
|
|
243
241
|
cell: {
|
|
@@ -125,11 +125,17 @@ module Prawn
|
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
def default_text_margin_bottom
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
text_line_gap +
|
|
129
|
+
text_descender +
|
|
130
|
+
text_leading
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def text_line_gap
|
|
134
|
+
@text_line_gap ||= with_font(text_options) { pdf.font.line_gap }
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def text_descender
|
|
138
|
+
@text_descender ||= with_font(text_options) { pdf.font.descender }
|
|
133
139
|
end
|
|
134
140
|
|
|
135
141
|
def text_leading
|
|
@@ -87,12 +87,17 @@ module Prawn
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def add_list(list)
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
pdf.move_up(additional_cell_padding_top)
|
|
91
|
+
draw_list(list)
|
|
92
|
+
put_bottom_margin(text_margin_bottom + additional_cell_padding_top)
|
|
92
93
|
rescue Prawn::Errors::CannotFit => e
|
|
93
94
|
append_text(list_too_large_placeholder(e))
|
|
94
95
|
end
|
|
95
96
|
|
|
97
|
+
def draw_list(list)
|
|
98
|
+
Builders::ListBuilder.new(pdf, list, pdf.bounds.width, options).draw
|
|
99
|
+
end
|
|
100
|
+
|
|
96
101
|
def list_too_large_placeholder(error)
|
|
97
102
|
placeholder_value(%i[list placeholder too_large], error) || '[list content too large]'
|
|
98
103
|
end
|
|
@@ -96,15 +96,24 @@ module Prawn
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def add_table(cells)
|
|
99
|
-
|
|
100
|
-
put_bottom_margin(text_margin_bottom)
|
|
99
|
+
draw_table(cells)
|
|
100
|
+
put_bottom_margin(text_margin_bottom + additional_cell_padding_top + text_leading)
|
|
101
101
|
rescue Prawn::Errors::CannotFit => e
|
|
102
102
|
append_text(table_too_large_placeholder(e))
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
+
def draw_table(cells)
|
|
106
|
+
Builders::TableBuilder.new(pdf, cells, pdf.bounds.width, options).draw
|
|
107
|
+
end
|
|
108
|
+
|
|
105
109
|
def table_too_large_placeholder(error)
|
|
106
110
|
placeholder_value(%i[table placeholder too_large], error) || '[table content too large]'
|
|
107
111
|
end
|
|
112
|
+
|
|
113
|
+
def additional_cell_padding_top
|
|
114
|
+
# as used in Prawn::Table::Cell::Text#draw_content move_down
|
|
115
|
+
(text_line_gap + text_descender) / 2
|
|
116
|
+
end
|
|
108
117
|
end
|
|
109
118
|
end
|
|
110
119
|
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.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pascal Zumkehr
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -210,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
210
210
|
- !ruby/object:Gem::Version
|
|
211
211
|
version: '0'
|
|
212
212
|
requirements: []
|
|
213
|
-
|
|
214
|
-
rubygems_version: 2.7.8
|
|
213
|
+
rubygems_version: 3.1.2
|
|
215
214
|
signing_key:
|
|
216
215
|
specification_version: 4
|
|
217
216
|
summary: Parse simple HTML markup to include in Prawn PDFs
|