premailer 1.14.2 → 1.16.0
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/README.md +2 -2
- data/lib/premailer/adapter/nokogiri.rb +2 -2
- data/lib/premailer/adapter/nokogiri_fast.rb +2 -2
- data/lib/premailer/adapter/nokogumbo.rb +2 -4
- data/lib/premailer/html_to_plain_text.rb +11 -15
- data/lib/premailer/premailer.rb +3 -9
- data/lib/premailer/version.rb +1 -1
- data/lib/premailer.rb +1 -1
- metadata +8 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5569e920c965e583c48c9f8501b77b951c73d07c9be2f922ab4924dc1166871
|
4
|
+
data.tar.gz: a8a665fe6ec7ba543b53ca24869e3c73bbf793cb003e4d27e4f854523309b605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc465f0f358d41f34ceef3c35fceda64f18d0b3e6ef27497dd649f4ce775c37a52d0f7ff12e5702e67ba6dc59760cedc5c706e8194a0b3063c9215644299f76
|
7
|
+
data.tar.gz: 78aa6ffd3c33aabc6eab536d09c4f00bb5a775e32db01b3445aa96530af1a1d950760de0cc99609008dd0d1af01d6976eacd298fb4acb705005070faa7c4c747
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Premailer README [](https://github.com/premailer/premailer/actions/workflows/actions.yml) [](https://badge.fury.io/rb/premailer)
|
2
2
|
|
3
3
|
## What is this?
|
4
4
|
|
@@ -68,7 +68,7 @@ Premailer::Adapter.use = :nokogiri_fast
|
|
68
68
|
|
69
69
|
## Ruby Compatibility
|
70
70
|
|
71
|
-
See .
|
71
|
+
See .github/workflows/actions.yml for which ruby versions are tested. JRuby support is close, contributors are welcome.
|
72
72
|
|
73
73
|
## Premailer-specific CSS
|
74
74
|
|
@@ -125,13 +125,13 @@ class Premailer
|
|
125
125
|
doc.search("a[@href^='#']").each do |el|
|
126
126
|
target = el.get_attribute('href')[1..-1]
|
127
127
|
targets << target
|
128
|
-
el.set_attribute('href', "#" + Digest::
|
128
|
+
el.set_attribute('href', "#" + Digest::SHA256.hexdigest(target))
|
129
129
|
end
|
130
130
|
# hash ids that are links target, delete others
|
131
131
|
doc.search("*[@id]").each do |el|
|
132
132
|
id = el.get_attribute('id')
|
133
133
|
if targets.include?(id)
|
134
|
-
el.set_attribute('id', Digest::
|
134
|
+
el.set_attribute('id', Digest::SHA256.hexdigest(id))
|
135
135
|
else
|
136
136
|
el.remove_attribute('id')
|
137
137
|
end
|
@@ -129,13 +129,13 @@ class Premailer
|
|
129
129
|
doc.search("a[@href^='#']").each do |el|
|
130
130
|
target = el.get_attribute('href')[1..-1]
|
131
131
|
targets << target
|
132
|
-
el.set_attribute('href', "#" + Digest::
|
132
|
+
el.set_attribute('href', "#" + Digest::SHA256.hexdigest(target))
|
133
133
|
end
|
134
134
|
# hash ids that are links target, delete others
|
135
135
|
doc.search("*[@id]").each do |el|
|
136
136
|
id = el.get_attribute('id')
|
137
137
|
if targets.include?(id)
|
138
|
-
el.set_attribute('id', Digest::
|
138
|
+
el.set_attribute('id', Digest::SHA256.hexdigest(id))
|
139
139
|
else
|
140
140
|
el.remove_attribute('id')
|
141
141
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'nokogumbo'
|
2
|
-
|
3
1
|
class Premailer
|
4
2
|
module Adapter
|
5
3
|
# Nokogiri adapter
|
@@ -125,13 +123,13 @@ class Premailer
|
|
125
123
|
doc.search("a[@href^='#']").each do |el|
|
126
124
|
target = el.get_attribute('href')[1..-1]
|
127
125
|
targets << target
|
128
|
-
el.set_attribute('href', "#" + Digest::
|
126
|
+
el.set_attribute('href', "#" + Digest::SHA256.hexdigest(target))
|
129
127
|
end
|
130
128
|
# hash ids that are links target, delete others
|
131
129
|
doc.search("*[@id]").each do |el|
|
132
130
|
id = el.get_attribute('id')
|
133
131
|
if targets.include?(id)
|
134
|
-
el.set_attribute('id', Digest::
|
132
|
+
el.set_attribute('id', Digest::SHA256.hexdigest(id))
|
135
133
|
else
|
136
134
|
el.remove_attribute('id')
|
137
135
|
end
|
@@ -39,25 +39,21 @@ module HtmlToPlainText
|
|
39
39
|
# remove script tags and content
|
40
40
|
txt.gsub!(/<script.*?\/script>/m, '')
|
41
41
|
|
42
|
-
# links
|
43
|
-
txt.gsub!(/<a\s
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
$3.strip + ' ( ' + $2.strip + ' )'
|
42
|
+
# links
|
43
|
+
txt.gsub!(/<a\s+([^>]+)>(.*?)<\/a>/im) do |s|
|
44
|
+
text = $2.strip
|
45
|
+
|
46
|
+
match = /href=(['"])(?:mailto:)?(.+?)\1/.match(s)
|
47
|
+
if match
|
48
|
+
href = match[2]
|
50
49
|
end
|
51
|
-
end
|
52
50
|
|
53
|
-
|
54
|
-
txt.gsub!(/<a\s[^\n]*?href=["'](mailto:)?([^']*)['][^>]*>(.*?)<\/a>/im) do |s|
|
55
|
-
if $3.empty?
|
51
|
+
if text.empty?
|
56
52
|
''
|
57
|
-
elsif
|
58
|
-
|
53
|
+
elsif href.nil? || text.strip.downcase == href.strip.downcase
|
54
|
+
text.strip
|
59
55
|
else
|
60
|
-
|
56
|
+
text.strip + ' ( ' + href.strip + ' )'
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
data/lib/premailer/premailer.rb
CHANGED
@@ -178,7 +178,7 @@ class Premailer
|
|
178
178
|
# @option options [String] :output_encoding Output encoding option for Nokogiri adapter. Should be set to "US-ASCII" to output HTML entities instead of Unicode characters.
|
179
179
|
# @option options [Boolean] :create_shorthands Combine several properties into a shorthand one, e.g. font: style weight size. Default is true.
|
180
180
|
# @option options [Boolean] :html_fragment Handle HTML fragment without any HTML content wrappers. Default is false.
|
181
|
-
# @option options [Boolean] :drop_unmergeable_css_rules Do not include unmergeable css rules in a <tt><style><tt> tag. Default is false.
|
181
|
+
# @option options [Boolean] :drop_unmergeable_css_rules Do not include unmergeable css rules in a <tt><style><tt> tag. Default is false.
|
182
182
|
def initialize(html, options = {})
|
183
183
|
@options = {:warn_level => Warnings::SAFE,
|
184
184
|
:line_length => 65,
|
@@ -499,14 +499,8 @@ public
|
|
499
499
|
def self.canonicalize(uri) # :nodoc:
|
500
500
|
u = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI.parse(uri.to_s)
|
501
501
|
u.normalize!
|
502
|
-
|
503
|
-
|
504
|
-
$1 == '..' ? match : ''
|
505
|
-
} do end
|
506
|
-
newpath = newpath.gsub(%r{/\./}, '/').sub(%r{/\.\z}, '/')
|
507
|
-
u.path = newpath
|
508
|
-
u.to_s
|
509
|
-
end
|
502
|
+
u.to_s
|
503
|
+
end
|
510
504
|
|
511
505
|
# Check <tt>CLIENT_SUPPORT_FILE</tt> for any CSS warnings
|
512
506
|
def check_client_support # :nodoc:
|
data/lib/premailer/version.rb
CHANGED
data/lib/premailer.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: premailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dunae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: css_parser
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
95
|
+
version: '1.13'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
102
|
+
version: '1.13'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: redcarpet
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,20 +156,6 @@ dependencies:
|
|
156
156
|
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: nokogumbo
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - ">="
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - ">="
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '0'
|
173
159
|
- !ruby/object:Gem::Dependency
|
174
160
|
name: bump
|
175
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +193,8 @@ files:
|
|
207
193
|
- lib/premailer/version.rb
|
208
194
|
- misc/client_support.yaml
|
209
195
|
homepage: https://github.com/premailer/premailer
|
210
|
-
licenses:
|
196
|
+
licenses:
|
197
|
+
- BSD-3-Clause
|
211
198
|
metadata:
|
212
199
|
yard.run: yri
|
213
200
|
post_install_message:
|
@@ -218,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
205
|
requirements:
|
219
206
|
- - ">="
|
220
207
|
- !ruby/object:Gem::Version
|
221
|
-
version: 2.
|
208
|
+
version: 2.7.0
|
222
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
210
|
requirements:
|
224
211
|
- - ">="
|
225
212
|
- !ruby/object:Gem::Version
|
226
213
|
version: '0'
|
227
214
|
requirements: []
|
228
|
-
rubygems_version: 3.1.
|
215
|
+
rubygems_version: 3.1.6
|
229
216
|
signing_key:
|
230
217
|
specification_version: 4
|
231
218
|
summary: Preflight for HTML e-mail.
|