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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bf5359f2a3cd6a08af1cb55a8f698a0ff16105d27a8de7c1e747f9f2ea521a1
4
- data.tar.gz: 3bd829e28c2bc4bc079834a9b0a21eb7d93ce57cfd3d511f2e511f2c8bd0cd4a
3
+ metadata.gz: e4e901d1a82b9468866e3355cf84908e59b8ae60670b71334d76409e58253b4d
4
+ data.tar.gz: 1cd88734f4a8e2f490c856b5c75478552c407b7e0757f5ff112277080fff0b2e
5
5
  SHA512:
6
- metadata.gz: b0e6c543856fb3fdd86e9d873b093faec9ac91049489512dc16cbc23fee6f77a33b7eff48d152fda4f0d4dd4d12374de05efed01a4e295cf1adccc42a7699280
7
- data.tar.gz: b5a02c1fa07ad2b2326e981f41b551d7f57b033ac196e94798f9d3250ed9ba76dd889709b77838c0eb8feebb5d7034309a03548ce5b0773d8c04d4c61103d335
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
- append_text("<color c=\"#{c}\" m=\"#{m}\" y=\"#{y}\" k=\"#{k}\">")
100
+ append_color_tag([c, m, y, k])
86
101
  else
87
- append_text("<color rgb=\"#{rgb}\">")
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) { |ctx| ctx.recovery = true }
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 = [])
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module Markup
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
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.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: 2023-06-14 00:00:00.000000000 Z
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.3.26
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