prawn-markup 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/prawn/markup/processor/text.rb +26 -2
- data/lib/prawn/markup/processor.rb +3 -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: e4e901d1a82b9468866e3355cf84908e59b8ae60670b71334d76409e58253b4d
|
4
|
+
data.tar.gz: 1cd88734f4a8e2f490c856b5c75478552c407b7e0757f5ff112277080fff0b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44e4d67545a64fc93c9ab5f6c35cfd8d9d095adaed07b9a6b3f0f1d6da7ce15a17c4c0882930658cc087bc397a43414e23f090aca1141326854590556bacc797
|
7
|
+
data.tar.gz: b7b2893c2f2d903bd79d6b02dff6d4e9ab338108952cdea4a1f1c18d8ad9682afe6eb249ce7ab044a4821c09cc94296f30c0e5dc7aae2b842a93effd42f09435
|
data/README.md
CHANGED
@@ -109,6 +109,9 @@ Beside these options handled by Prawn / prawn-table, the following values may be
|
|
109
109
|
- `:radio`
|
110
110
|
- `:checked`: The char to print for a checked radio. Default is '◉'.
|
111
111
|
- `:unchecked`: The char to print for an unchecked radio. Default is '○'.
|
112
|
+
- `:link`
|
113
|
+
- `:color`: The link color, which can be specified in either RGB hex format or 4-value CMYK.
|
114
|
+
- `:underline`: Specifies whether the link should be underlined. Default is false.
|
112
115
|
|
113
116
|
## Development
|
114
117
|
|
@@ -11,15 +11,30 @@ module Prawn
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def start_a
|
14
|
+
start_u if link_options[:underline]
|
15
|
+
append_color_tag(link_options[:color]) if link_options[:color]
|
14
16
|
append_text("<link href=\"#{current_attrs['href']}\">")
|
15
17
|
end
|
16
18
|
alias start_link start_a
|
17
19
|
|
18
20
|
def end_a
|
19
21
|
append_text('</link>')
|
22
|
+
end_color if link_options[:color]
|
23
|
+
end_u if link_options[:underline]
|
20
24
|
end
|
21
25
|
alias end_link end_a
|
22
26
|
|
27
|
+
def link_options
|
28
|
+
@link_options ||= HashMerger.deep(default_link_options, options[:link] || {})
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_link_options
|
32
|
+
{
|
33
|
+
color: nil,
|
34
|
+
underline: false
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
23
38
|
def start_b
|
24
39
|
append_text('<b>')
|
25
40
|
end
|
@@ -82,9 +97,9 @@ module Prawn
|
|
82
97
|
rgb, c, m, y, k = current_attrs.values_at('rgb', 'c', 'm', 'y', 'k')
|
83
98
|
|
84
99
|
if [c, m, y, k].all?
|
85
|
-
|
100
|
+
append_color_tag([c, m, y, k])
|
86
101
|
else
|
87
|
-
|
102
|
+
append_color_tag(rgb)
|
88
103
|
end
|
89
104
|
end
|
90
105
|
|
@@ -103,6 +118,15 @@ module Prawn
|
|
103
118
|
def end_font
|
104
119
|
append_text('</font>')
|
105
120
|
end
|
121
|
+
|
122
|
+
def append_color_tag(color)
|
123
|
+
if color.is_a?(Array)
|
124
|
+
c, m, y, k = color
|
125
|
+
append_text("<color c=\"#{c}\" m=\"#{m}\" y=\"#{y}\" k=\"#{k}\">")
|
126
|
+
else
|
127
|
+
append_text("<color rgb=\"#{color}\">")
|
128
|
+
end
|
129
|
+
end
|
106
130
|
end
|
107
131
|
end
|
108
132
|
end
|
@@ -49,7 +49,9 @@ module Prawn
|
|
49
49
|
|
50
50
|
reset
|
51
51
|
html = Prawn::Markup::Normalizer.new(html).normalize
|
52
|
-
Nokogiri::HTML::SAX::Parser.new(self).parse(html)
|
52
|
+
Nokogiri::HTML::SAX::Parser.new(self, html.encoding&.to_s).parse(html) do |ctx|
|
53
|
+
ctx.recovery = true
|
54
|
+
end
|
53
55
|
end
|
54
56
|
|
55
57
|
def start_element(name, attrs = [])
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '0'
|
218
218
|
requirements: []
|
219
|
-
rubygems_version: 3.
|
219
|
+
rubygems_version: 3.5.22
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
222
|
summary: Parse simple HTML markup to include in Prawn PDFs
|