prawn-markup 0.3.0 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/prawn/markup/builders/list_builder.rb +1 -1
- data/lib/prawn/markup/processor/images.rb +9 -2
- data/lib/prawn/markup/processor/lists.rb +5 -3
- data/lib/prawn/markup/processor.rb +10 -8
- data/lib/prawn/markup/support/size_converter.rb +1 -1
- data/lib/prawn/markup/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5217761bc64b6cf5ae6697d326934a9b87d3e54a3a65428f9c7025d3a03f043
|
4
|
+
data.tar.gz: c3274d3dfd6ab699f4d9fe17db8148305c9b4c4c7da8cd3b2a8b834735380583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 728da10a3ce7d80aca95a3b9d54d9122c9c791567ab150188c6f459bb0de15863524322d091ed01900e844661aa0e5337542fd191f03eb97d080e27b905cc394
|
7
|
+
data.tar.gz: c701c14bcc7fd0baa8cb17179f5096caef7a8f8ce829f8d548d9667d5ce78f2ec2248a1848eca32e01cb0e52e94befb0a845a9d6da0f14c851fb195420e9c90f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Prawn::Markup
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/puzzle/prawn-markup/actions/workflows/build.yml/badge.svg)](https://github.com/puzzle/prawn-markup/actions/workflows/build.yml)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/52a462f9d65e33352d4e/maintainability)](https://codeclimate.com/github/puzzle/prawn-markup/maintainability)
|
5
5
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/52a462f9d65e33352d4e/test_coverage)](https://codeclimate.com/github/puzzle/prawn-markup/test_coverage)
|
6
6
|
|
@@ -69,7 +69,7 @@ module Prawn
|
|
69
69
|
def list_item_table(item)
|
70
70
|
data = item.nodes.map { |n| [normalize_list_item_node(n)] }
|
71
71
|
style = column_cell_style(:content)
|
72
|
-
.merge(borders: [], padding: [0, 0, padding_bottom, 0])
|
72
|
+
.merge(borders: [], padding: [0, 0, padding_bottom, 0], inline_format: true)
|
73
73
|
pdf.make_table(data, cell_style: style, column_widths: [content_width]) do
|
74
74
|
rows(-1).padding = [0, 0, 0, 0]
|
75
75
|
end
|
@@ -12,8 +12,11 @@ module Prawn
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def start_img
|
15
|
+
src = current_attrs['src']
|
16
|
+
return if src.to_s.strip.empty?
|
17
|
+
|
15
18
|
add_current_text
|
16
|
-
add_image_or_placeholder(
|
19
|
+
add_image_or_placeholder(src)
|
17
20
|
end
|
18
21
|
|
19
22
|
def start_iframe
|
@@ -70,7 +73,11 @@ module Prawn
|
|
70
73
|
|
71
74
|
def load_remote_image(src)
|
72
75
|
if src =~ %r{^https?:/}
|
73
|
-
|
76
|
+
begin
|
77
|
+
URI.parse(src).open
|
78
|
+
rescue OpenURI::HTTPError, SocketError
|
79
|
+
nil
|
80
|
+
end
|
74
81
|
end
|
75
82
|
end
|
76
83
|
|
@@ -34,13 +34,13 @@ module Prawn
|
|
34
34
|
alias end_ul end_list
|
35
35
|
|
36
36
|
def start_li
|
37
|
-
return unless
|
37
|
+
return unless current_list
|
38
38
|
|
39
39
|
current_list.items << Elements::Item.new
|
40
40
|
end
|
41
41
|
|
42
42
|
def end_li
|
43
|
-
return unless
|
43
|
+
return unless current_list
|
44
44
|
|
45
45
|
add_cell_text_node(current_list_item)
|
46
46
|
end
|
@@ -67,7 +67,9 @@ module Prawn
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def current_list_item
|
70
|
-
current_list.items
|
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?
|
@@ -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:
|
56
|
-
if
|
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(
|
71
|
+
logger.info("SAX parsing error: #{string.strip}") if logger
|
73
72
|
end
|
74
73
|
|
75
74
|
def warning(string)
|
76
|
-
logger.info(
|
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
|
-
|
126
|
-
Hash[tokens]
|
128
|
+
style.split(';').map { |p| p.split(':', 2).map(&:strip) }.to_h
|
127
129
|
else
|
128
130
|
{}
|
129
131
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Zumkehr
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -187,7 +187,7 @@ homepage: https://github.com/puzzle/prawn-markup
|
|
187
187
|
licenses:
|
188
188
|
- MIT
|
189
189
|
metadata: {}
|
190
|
-
post_install_message:
|
190
|
+
post_install_message:
|
191
191
|
rdoc_options: []
|
192
192
|
require_paths:
|
193
193
|
- lib
|
@@ -202,8 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.
|
206
|
-
signing_key:
|
205
|
+
rubygems_version: 3.1.4
|
206
|
+
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Parse simple HTML markup to include in Prawn PDFs
|
209
209
|
test_files: []
|