premailer 1.8.2 → 1.8.3
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/.travis.yml +9 -5
- data/.yardopts +0 -1
- data/README.md +1 -1
- data/gemfiles/{ruby187.gemfile → .ruby187.gemfile} +0 -0
- data/gemfiles/ruby187.gemspec +1 -1
- data/lib/premailer/adapter/hpricot.rb +7 -1
- data/lib/premailer/adapter/nokogiri.rb +14 -4
- data/lib/premailer/html_to_plain_text.rb +2 -2
- data/lib/premailer/premailer.rb +6 -5
- data/lib/premailer/version.rb +1 -1
- data/premailer.gemspec +3 -4
- data/test/files/ignore.css +3 -0
- data/test/files/ignore.html +15 -0
- data/test/test_misc.rb +48 -0
- data/test/test_premailer.rb +56 -23
- metadata +42 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0dc8865cdf0b882aeeb72fccd4b1cd8d6fc7029
|
4
|
+
data.tar.gz: 22d249d5230128f64b4b605a25f90bcc1e8fd772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d28472cc7b50fce5299f6f2a6b1ed98a9c1f04ce2cccafc243e2cdb91ef78ffe29170bcb498b662feba9349200bf2eb956e2fd2efe957a2a27baf6e2a377d42
|
7
|
+
data.tar.gz: 729a44fbbf61a243216b08ed0501ea15a7f55d90722811444d815eef4f6884ddb2f10426a590dcf224e3692529b484d824f2b6979679dc994b76a1e94e16ce57
|
data/.travis.yml
CHANGED
@@ -5,19 +5,23 @@ rvm:
|
|
5
5
|
- 1.9.2
|
6
6
|
- 1.9.3
|
7
7
|
- 2.0.0
|
8
|
+
- 2.1.0
|
8
9
|
- ree
|
9
10
|
gemfile:
|
10
11
|
- Gemfile
|
11
|
-
- gemfiles
|
12
|
+
- gemfiles/.ruby187.gemfile
|
13
|
+
env:
|
14
|
+
global:
|
15
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
12
16
|
matrix:
|
13
17
|
exclude:
|
14
18
|
- rvm: 1.8.7
|
15
19
|
gemfile: Gemfile
|
16
20
|
- rvm: 1.9.2
|
17
|
-
gemfile: gemfiles
|
21
|
+
gemfile: gemfiles/.ruby187.gemfile
|
18
22
|
- rvm: 1.9.3
|
19
|
-
gemfile: gemfiles
|
23
|
+
gemfile: gemfiles/.ruby187.gemfile
|
20
24
|
- rvm: 2.0.0
|
21
|
-
gemfile: gemfiles
|
25
|
+
gemfile: gemfiles/.ruby187.gemfile
|
22
26
|
- rvm: ree
|
23
|
-
gemfile: Gemfile
|
27
|
+
gemfile: Gemfile
|
data/.yardopts
CHANGED
data/README.md
CHANGED
File without changes
|
data/gemfiles/ruby187.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
21
|
s.add_dependency('css_parser', '>= 1.3.5')
|
22
|
-
s.add_dependency('htmlentities', '>= 4.0.0')
|
22
|
+
s.add_dependency('htmlentities', [ '>= 4.0.0', '<= 4.3.1' ])
|
23
23
|
s.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
s.add_development_dependency('rake', ['~> 0.8', '!= 0.9.0'])
|
25
25
|
s.add_development_dependency('hpricot', '>= 0.8.3')
|
@@ -80,7 +80,7 @@ class Premailer
|
|
80
80
|
# Duplicate CSS attributes as HTML attributes
|
81
81
|
if Premailer::RELATED_ATTRIBUTES.has_key?(el.name)
|
82
82
|
Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
|
83
|
-
el[html_att] = merged[css_att].gsub(/url\('(.*)'\)/,'\1').gsub(
|
83
|
+
el[html_att] = merged[css_att].gsub(/url\('(.*)'\)/,'\1').gsub(/;$|\s*!important/, '').strip if el[html_att].nil? and not merged[css_att].empty?
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -102,6 +102,12 @@ class Premailer
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
if @options[:reset_contenteditable]
|
106
|
+
doc.search('*[@contenteditable]').each do |el|
|
107
|
+
el.remove_attribute('contenteditable')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
105
111
|
if @options[:remove_ids]
|
106
112
|
# find all anchor's targets and hash them
|
107
113
|
targets = []
|
@@ -76,7 +76,7 @@ class Premailer
|
|
76
76
|
# Duplicate CSS attributes as HTML attributes
|
77
77
|
if Premailer::RELATED_ATTRIBUTES.has_key?(el.name)
|
78
78
|
Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
|
79
|
-
el[html_att] = merged[css_att].gsub(/url\('(.*)'\)/,'\1').gsub(
|
79
|
+
el[html_att] = merged[css_att].gsub(/url\('(.*)'\)/,'\1').gsub(/;$|\s*!important/, '').strip if el[html_att].nil? and not merged[css_att].empty?
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -118,6 +118,12 @@ class Premailer
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
if @options[:reset_contenteditable]
|
122
|
+
doc.search('*[@contenteditable]').each do |el|
|
123
|
+
el.remove_attribute('contenteditable')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
121
127
|
@processed_doc = doc
|
122
128
|
if is_xhtml?
|
123
129
|
# we don't want to encode carriage returns
|
@@ -216,9 +222,13 @@ class Premailer
|
|
216
222
|
doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding] || default_encoding) {|c| c.recover }
|
217
223
|
end
|
218
224
|
|
219
|
-
# Fix for removing any CDATA tags inserted per
|
220
|
-
|
221
|
-
|
225
|
+
# Fix for removing any CDATA tags from both style and script tags inserted per
|
226
|
+
# https://github.com/sparklemotion/nokogiri/issues/311 and
|
227
|
+
# https://github.com/premailer/premailer/issues/199
|
228
|
+
%w(style script).each do |tag|
|
229
|
+
doc.search(tag).children.each do |child|
|
230
|
+
child.swap(child.text()) if child.cdata?
|
231
|
+
end
|
222
232
|
end
|
223
233
|
|
224
234
|
doc
|
@@ -26,7 +26,7 @@ module HtmlToPlainText
|
|
26
26
|
txt.gsub!(/<img.+?alt=\'([^\']*)\'[^>]*\>/i, '\1')
|
27
27
|
|
28
28
|
# links
|
29
|
-
txt.gsub!(/<a
|
29
|
+
txt.gsub!(/<a\s.*?href=\"(mailto:)?([^\"]*)\"[^>]*>((.|\s)*?)<\/a>/i) do |s|
|
30
30
|
if $3.empty?
|
31
31
|
''
|
32
32
|
else
|
@@ -34,7 +34,7 @@ module HtmlToPlainText
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
txt.gsub!(/<a
|
37
|
+
txt.gsub!(/<a\s.*?href='(mailto:)?([^\']*)\'[^>]*>((.|\s)*?)<\/a>/i) do |s|
|
38
38
|
if $3.empty?
|
39
39
|
''
|
40
40
|
else
|
data/lib/premailer/premailer.rb
CHANGED
@@ -145,8 +145,8 @@ class Premailer
|
|
145
145
|
# must set the with_html_string option to true.
|
146
146
|
#
|
147
147
|
# @param [Hash] options the options to handle html with.
|
148
|
-
# @option options [
|
149
|
-
# @option options [
|
148
|
+
# @option options [Fixnum] :line_length Line length used by to_plain_text. Default is 65.
|
149
|
+
# @option options [Fixnum] :warn_level What level of CSS compatibility warnings to show (see {Premailer::Warnings}).
|
150
150
|
# @option options [String] :link_query_string A string to append to every <tt>a href=""</tt> link. Do not include the initial <tt>?</tt>.
|
151
151
|
# @option options [String] :base_url Used to calculate absolute URLs for local files.
|
152
152
|
# @option options [Array(String)] :css Manually specify CSS stylesheets.
|
@@ -156,6 +156,7 @@ class Premailer
|
|
156
156
|
# @option options [Boolean] :remove_classes Remove class attributes. Default is false.
|
157
157
|
# @option options [Boolean] :remove_comments Remove html comments. Default is false.
|
158
158
|
# @option options [Boolean] :remove_scripts Remove <tt>script</tt> elements. Default is true.
|
159
|
+
# @option options [Boolean] :reset_contenteditable Remove <tt>contenteditable</tt> attributes. Default is true.
|
159
160
|
# @option options [Boolean] :preserve_styles Whether to preserve any <tt>link rel=stylesheet</tt> and <tt>style</tt> elements. Default is false.
|
160
161
|
# @option options [Boolean] :preserve_reset Whether to preserve styles associated with the MailChimp reset code. Default is true.
|
161
162
|
# @option options [Boolean] :with_html_string Whether the html param should be treated as a raw string. Default is false.
|
@@ -176,6 +177,7 @@ class Premailer
|
|
176
177
|
:remove_ids => false,
|
177
178
|
:remove_comments => false,
|
178
179
|
:remove_scripts => true,
|
180
|
+
:reset_contenteditable => true,
|
179
181
|
:css => [],
|
180
182
|
:css_to_attributes => true,
|
181
183
|
:with_html_string => false,
|
@@ -275,9 +277,9 @@ protected
|
|
275
277
|
# Load CSS included in <tt>style</tt> and <tt>link</tt> tags from an HTML document.
|
276
278
|
def load_css_from_html! # :nodoc:
|
277
279
|
if (@options[:adapter] == :nokogiri)
|
278
|
-
tags = @doc.search("link[@rel='stylesheet']", "//style[not(contains(@data-premailer,'ignore'))]")
|
280
|
+
tags = @doc.search("link[@rel='stylesheet']:not([@data-premailer='ignore'])", "//style[not(contains(@data-premailer,'ignore'))]")
|
279
281
|
else
|
280
|
-
tags = @doc.search("link[@rel='stylesheet'], style:not([@data-premailer='ignore'])")
|
282
|
+
tags = @doc.search("link[@rel='stylesheet']:not([@data-premailer='ignore']), style:not([@data-premailer='ignore'])")
|
281
283
|
end
|
282
284
|
if tags
|
283
285
|
tags.each do |tag|
|
@@ -545,4 +547,3 @@ public
|
|
545
547
|
warnings
|
546
548
|
end
|
547
549
|
end
|
548
|
-
|
data/lib/premailer/version.rb
CHANGED
data/premailer.gemspec
CHANGED
@@ -18,14 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
|
-
s.add_dependency('css_parser', '>= 1.3.
|
22
|
-
s.add_dependency('htmlentities', '>= 4.0.0')
|
21
|
+
s.add_dependency('css_parser', '>= 1.3.6')
|
22
|
+
s.add_dependency('htmlentities', [ '>= 4.0.0', '<= 4.3.1' ])
|
23
23
|
s.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
s.add_development_dependency('rake', ['~> 0.8', '!= 0.9.0'])
|
25
25
|
s.add_development_dependency('hpricot', '>= 0.8.3')
|
26
26
|
s.add_development_dependency('nokogiri', '>= 1.4.4')
|
27
|
-
s.add_development_dependency('yard', '~> 0.8.7')
|
27
|
+
s.add_development_dependency('yard', '~> 0.8.7.6')
|
28
28
|
s.add_development_dependency('redcarpet', '~> 3.0')
|
29
|
-
s.add_development_dependency "yard-redcarpet-ext", "~> 0.0.3"
|
30
29
|
end
|
31
30
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Should ignore link and style elements with data attribute</title>
|
5
|
+
<link rel="stylesheet" type="text/css" href="ignore.css" data-premailer="ignore" />
|
6
|
+
<style type="text/css" data-premailer="ignore">
|
7
|
+
h1 {
|
8
|
+
color: red;
|
9
|
+
}
|
10
|
+
</style>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>Content</h1>
|
14
|
+
</body>
|
15
|
+
</html>
|
data/test/test_misc.rb
CHANGED
@@ -322,4 +322,52 @@ END_HTML
|
|
322
322
|
end
|
323
323
|
end
|
324
324
|
|
325
|
+
def test_strip_important_from_attributes
|
326
|
+
html = <<END_HTML
|
327
|
+
<html>
|
328
|
+
<head>
|
329
|
+
<style>td { background-color: #FF0000 !important; }</style>
|
330
|
+
</head>
|
331
|
+
<body>
|
332
|
+
<table><tr><td>red</td></tr></table>
|
333
|
+
</body>
|
334
|
+
</html>
|
335
|
+
END_HTML
|
336
|
+
|
337
|
+
[:nokogiri, :hpricot].each do |adapter|
|
338
|
+
premailer = Premailer.new(html, :with_html_string => true, :adapter => adapter)
|
339
|
+
assert_match 'bgcolor="#FF0000"', premailer.to_inline_css
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_scripts_with_nokogiri
|
344
|
+
html = <<END_HTML
|
345
|
+
<html>
|
346
|
+
<body>
|
347
|
+
<script type="application/ld+json">
|
348
|
+
{
|
349
|
+
"@context": "http://schema.org",
|
350
|
+
"@type": "Person",
|
351
|
+
"name": "John Doe",
|
352
|
+
"jobTitle": "Graduate research assistant",
|
353
|
+
"affiliation": "University of Dreams",
|
354
|
+
"additionalName": "Johnny",
|
355
|
+
"url": "http://www.example.com",
|
356
|
+
"address": {
|
357
|
+
"@type": "PostalAddress",
|
358
|
+
"streetAddress": "1234 Peach Drive",
|
359
|
+
"addressLocality": "Wonderland",
|
360
|
+
"addressRegion": "Georgia"
|
361
|
+
}
|
362
|
+
}
|
363
|
+
</script
|
364
|
+
</body>
|
365
|
+
</html>
|
366
|
+
END_HTML
|
367
|
+
|
368
|
+
premailer = Premailer.new(html, :with_html_string => true, :remove_scripts => false, :adapter => :nokogiri)
|
369
|
+
premailer.to_inline_css
|
370
|
+
|
371
|
+
assert !premailer.processed_doc.css('script[type="application/ld+json"]').first.children.first.cdata?
|
372
|
+
end
|
325
373
|
end
|
data/test/test_premailer.rb
CHANGED
@@ -17,7 +17,7 @@ class TestPremailer < Premailer::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
#def test_cyrillic_nokogiri_remote
|
20
|
-
# if RUBY_VERSION =~ /1.9/
|
20
|
+
# if RUBY_VERSION =~ /1.9/
|
21
21
|
# remote_setup('iso-8859-5.html', :adapter => :nokogiri) #, :encoding => 'iso-8859-5')
|
22
22
|
# @premailer.to_inline_css
|
23
23
|
# assert_equal Encoding.find('ISO-8859-5'), @premailer.processed_doc.at('p').inner_html.encoding
|
@@ -32,7 +32,7 @@ class TestPremailer < Premailer::TestCase
|
|
32
32
|
premailer.to_inline_css
|
33
33
|
assert_equal 'cédille cé & garçon garçon à à &', premailer.processed_doc.at('p').inner_html
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def test_detecting_html
|
37
37
|
[:nokogiri, :hpricot].each do |adapter|
|
38
38
|
remote_setup('base.html', :adapter => adapter)
|
@@ -62,7 +62,7 @@ class TestPremailer < Premailer::TestCase
|
|
62
62
|
assert_match /<br>/, @premailer.to_inline_css
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
def test_mailtos_with_query_strings
|
67
67
|
html = <<END_HTML
|
68
68
|
<html>
|
@@ -75,17 +75,33 @@ END_HTML
|
|
75
75
|
[:nokogiri, :hpricot].each do |adapter|
|
76
76
|
premailer = Premailer.new(html, :with_html_string => true, :link_query_string => qs, :adapter => adapter)
|
77
77
|
premailer.to_inline_css
|
78
|
-
assert_no_match /testing=123/, premailer.processed_doc.search('a').first.attributes['href'].to_s
|
78
|
+
assert_no_match /testing=123/, premailer.processed_doc.search('a').first.attributes['href'].to_s
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def test_escaping_strings
|
83
83
|
local_setup
|
84
|
-
|
84
|
+
|
85
85
|
str = %q{url("/images/test.png");}
|
86
86
|
assert_equal("url(\'/images/test.png\');", Premailer.escape_string(str))
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
|
+
def test_preserving_ignored_style_elements
|
90
|
+
[:nokogiri, :hpricot].each do |adapter|
|
91
|
+
local_setup('ignore.html', :adapter => adapter)
|
92
|
+
|
93
|
+
assert_nil @doc.at('h1')['style']
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_preserving_ignored_link_elements
|
98
|
+
[:nokogiri, :hpricot].each do |adapter|
|
99
|
+
local_setup('ignore.html', :adapter => adapter)
|
100
|
+
|
101
|
+
assert_nil @doc.at('body')['style']
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
89
105
|
def test_importing_local_css
|
90
106
|
# , :hpricot
|
91
107
|
[:nokogiri].each do |adapter|
|
@@ -93,8 +109,8 @@ END_HTML
|
|
93
109
|
|
94
110
|
# noimport.css (print stylesheet) sets body { background } to red
|
95
111
|
assert_no_match /red/, @doc.at('body').attributes['style'].to_s
|
96
|
-
|
97
|
-
# import.css sets .hide to { display: none }
|
112
|
+
|
113
|
+
# import.css sets .hide to { display: none }
|
98
114
|
assert_match /display: none/, @doc.at('#hide01').attributes['style'].to_s
|
99
115
|
end
|
100
116
|
end
|
@@ -102,11 +118,11 @@ END_HTML
|
|
102
118
|
def test_importing_remote_css
|
103
119
|
[:nokogiri, :hpricot].each do |adapter|
|
104
120
|
remote_setup('base.html', :adapter => adapter)
|
105
|
-
|
121
|
+
|
106
122
|
# noimport.css (print stylesheet) sets body { background } to red
|
107
123
|
assert_no_match /red/, @doc.at('body')['style']
|
108
|
-
|
109
|
-
# import.css sets .hide to { display: none }
|
124
|
+
|
125
|
+
# import.css sets .hide to { display: none }
|
110
126
|
assert_match /display: none/, @doc.at('#hide01')['style']
|
111
127
|
end
|
112
128
|
end
|
@@ -130,12 +146,12 @@ END_HTML
|
|
130
146
|
assert Premailer.local_data?( StringIO.new('a') )
|
131
147
|
assert Premailer.local_data?( '/path/' )
|
132
148
|
assert !Premailer.local_data?( 'http://example.com/path/' )
|
133
|
-
|
149
|
+
|
134
150
|
# the old way is deprecated but should still work
|
135
151
|
premailer = Premailer.new( StringIO.new('a') )
|
136
152
|
assert premailer.local_uri?( '/path/' )
|
137
153
|
end
|
138
|
-
|
154
|
+
|
139
155
|
def test_initialize_can_accept_io_object
|
140
156
|
[:nokogiri, :hpricot].each do |adapter|
|
141
157
|
io = StringIO.new('hi mom')
|
@@ -143,14 +159,14 @@ END_HTML
|
|
143
159
|
assert_match /hi mom/, premailer.to_inline_css
|
144
160
|
end
|
145
161
|
end
|
146
|
-
|
162
|
+
|
147
163
|
def test_initialize_can_accept_html_string
|
148
164
|
[:nokogiri, :hpricot].each do |adapter|
|
149
165
|
premailer = Premailer.new('<p>test</p>', :with_html_string => true, :adapter => adapter)
|
150
166
|
assert_match /test/, premailer.to_inline_css
|
151
167
|
end
|
152
168
|
end
|
153
|
-
|
169
|
+
|
154
170
|
def test_initialize_no_escape_attributes_option
|
155
171
|
html = <<END_HTML
|
156
172
|
<html> <body>
|
@@ -167,12 +183,12 @@ END_HTML
|
|
167
183
|
assert_equal doc.at('#noescape')['href'], '{{link_url}}'
|
168
184
|
end
|
169
185
|
end
|
170
|
-
|
186
|
+
|
171
187
|
def test_remove_ids
|
172
188
|
html = <<END_HTML
|
173
189
|
<html> <head> <style type="text/css"> #remove { color:blue; } </style> </head>
|
174
190
|
<body>
|
175
|
-
<p id="remove"><a href="#keep">Test</a></p>
|
191
|
+
<p id="remove"><a href="#keep">Test</a></p>
|
176
192
|
<p id="keep">Test</p>
|
177
193
|
</body> </html>
|
178
194
|
END_HTML
|
@@ -187,7 +203,24 @@ END_HTML
|
|
187
203
|
assert_not_nil doc.at("\##{hashed_id}")
|
188
204
|
end
|
189
205
|
end
|
190
|
-
|
206
|
+
|
207
|
+
def test_reset_contenteditable
|
208
|
+
html = <<-___
|
209
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
210
|
+
<html> <head> <style type="text/css"> #remove { color:blue; } </style> </head>
|
211
|
+
<body>
|
212
|
+
<div contenteditable="true" id="editable"> Test </div>
|
213
|
+
</body> </html>
|
214
|
+
___
|
215
|
+
[:nokogiri, :hpricot].each do |adapter|
|
216
|
+
pm = Premailer.new(html, :with_html_string => true, :reset_contenteditable => true, :adapter => adapter)
|
217
|
+
pm.to_inline_css
|
218
|
+
doc = pm.processed_doc
|
219
|
+
assert_nil doc.at('#editable')['contenteditable'],
|
220
|
+
"#{adapter}: contenteditable attribute not removed"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
191
224
|
def test_carriage_returns_as_entities
|
192
225
|
html = <<-html
|
193
226
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
@@ -201,14 +234,14 @@ END_HTML
|
|
201
234
|
assert_match /\r/, pm.to_inline_css
|
202
235
|
end
|
203
236
|
end
|
204
|
-
|
205
|
-
|
237
|
+
|
238
|
+
|
206
239
|
def test_advanced_selectors
|
207
240
|
remote_setup('base.html', :adapter => :nokogiri)
|
208
241
|
assert_match /italic/, @doc.at('h2 + h3')['style']
|
209
242
|
assert_match /italic/, @doc.at('p[attr~=quote]')['style']
|
210
243
|
assert_match /italic/, @doc.at('ul li:first-of-type')['style']
|
211
|
-
|
244
|
+
|
212
245
|
remote_setup('base.html', :adapter => :hpricot)
|
213
246
|
assert_match /italic/, @doc.at('p[@attr~="quote"]')['style']
|
214
247
|
assert_match /italic/, @doc.at('ul li:first-of-type')['style']
|
@@ -294,7 +327,7 @@ END_HTML
|
|
294
327
|
def test_line_starting_with_uri_in_html_with_linked_css
|
295
328
|
files_base = File.expand_path(File.dirname(__FILE__)) + '/files/'
|
296
329
|
html_string = IO.read(File.join(files_base, 'html_with_uri.html'))
|
297
|
-
|
330
|
+
|
298
331
|
assert_nothing_raised do
|
299
332
|
premailer = Premailer.new(html_string, :with_html_string => true)
|
300
333
|
premailer.to_inline_css
|
metadata
CHANGED
@@ -1,147 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: premailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.3
|
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: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: css_parser
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.3.
|
19
|
+
version: 1.3.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.3.
|
26
|
+
version: 1.3.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: htmlentities
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 4.0.0
|
34
|
+
- - "<="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 4.3.1
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- -
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 4.0.0
|
44
|
+
- - "<="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 4.3.1
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - ~>
|
51
|
+
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '1.3'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - ~>
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '1.3'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - ~>
|
65
|
+
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0.8'
|
62
|
-
- -
|
68
|
+
- - "!="
|
63
69
|
- !ruby/object:Gem::Version
|
64
70
|
version: 0.9.0
|
65
71
|
type: :development
|
66
72
|
prerelease: false
|
67
73
|
version_requirements: !ruby/object:Gem::Requirement
|
68
74
|
requirements:
|
69
|
-
- - ~>
|
75
|
+
- - "~>"
|
70
76
|
- !ruby/object:Gem::Version
|
71
77
|
version: '0.8'
|
72
|
-
- -
|
78
|
+
- - "!="
|
73
79
|
- !ruby/object:Gem::Version
|
74
80
|
version: 0.9.0
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
82
|
name: hpricot
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
78
84
|
requirements:
|
79
|
-
- -
|
85
|
+
- - ">="
|
80
86
|
- !ruby/object:Gem::Version
|
81
87
|
version: 0.8.3
|
82
88
|
type: :development
|
83
89
|
prerelease: false
|
84
90
|
version_requirements: !ruby/object:Gem::Requirement
|
85
91
|
requirements:
|
86
|
-
- -
|
92
|
+
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
88
94
|
version: 0.8.3
|
89
95
|
- !ruby/object:Gem::Dependency
|
90
96
|
name: nokogiri
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
92
98
|
requirements:
|
93
|
-
- -
|
99
|
+
- - ">="
|
94
100
|
- !ruby/object:Gem::Version
|
95
101
|
version: 1.4.4
|
96
102
|
type: :development
|
97
103
|
prerelease: false
|
98
104
|
version_requirements: !ruby/object:Gem::Requirement
|
99
105
|
requirements:
|
100
|
-
- -
|
106
|
+
- - ">="
|
101
107
|
- !ruby/object:Gem::Version
|
102
108
|
version: 1.4.4
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
110
|
name: yard
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
107
|
-
- - ~>
|
113
|
+
- - "~>"
|
108
114
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.8.7
|
115
|
+
version: 0.8.7.6
|
110
116
|
type: :development
|
111
117
|
prerelease: false
|
112
118
|
version_requirements: !ruby/object:Gem::Requirement
|
113
119
|
requirements:
|
114
|
-
- - ~>
|
120
|
+
- - "~>"
|
115
121
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.8.7
|
122
|
+
version: 0.8.7.6
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
124
|
name: redcarpet
|
119
125
|
requirement: !ruby/object:Gem::Requirement
|
120
126
|
requirements:
|
121
|
-
- - ~>
|
127
|
+
- - "~>"
|
122
128
|
- !ruby/object:Gem::Version
|
123
129
|
version: '3.0'
|
124
130
|
type: :development
|
125
131
|
prerelease: false
|
126
132
|
version_requirements: !ruby/object:Gem::Requirement
|
127
133
|
requirements:
|
128
|
-
- - ~>
|
134
|
+
- - "~>"
|
129
135
|
- !ruby/object:Gem::Version
|
130
136
|
version: '3.0'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: yard-redcarpet-ext
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - ~>
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: 0.0.3
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - ~>
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: 0.0.3
|
145
137
|
description: Improve the rendering of HTML emails by making CSS inline, converting
|
146
138
|
links and warning about unsupported code.
|
147
139
|
email: code@dunae.ca
|
@@ -150,15 +142,15 @@ executables:
|
|
150
142
|
extensions: []
|
151
143
|
extra_rdoc_files: []
|
152
144
|
files:
|
153
|
-
- .gitignore
|
154
|
-
- .jrubyrc
|
155
|
-
- .travis.yml
|
156
|
-
- .yardopts
|
145
|
+
- ".gitignore"
|
146
|
+
- ".jrubyrc"
|
147
|
+
- ".travis.yml"
|
148
|
+
- ".yardopts"
|
157
149
|
- Gemfile
|
158
150
|
- LICENSE.md
|
159
151
|
- README.md
|
160
152
|
- bin/premailer
|
161
|
-
- gemfiles
|
153
|
+
- gemfiles/.ruby187.gemfile
|
162
154
|
- gemfiles/ruby187.gemspec
|
163
155
|
- init.rb
|
164
156
|
- lib/premailer.rb
|
@@ -181,6 +173,8 @@ files:
|
|
181
173
|
- test/files/dots_h.gif
|
182
174
|
- test/files/html4.html
|
183
175
|
- test/files/html_with_uri.html
|
176
|
+
- test/files/ignore.css
|
177
|
+
- test/files/ignore.html
|
184
178
|
- test/files/import.css
|
185
179
|
- test/files/inc/2009-placeholder.png
|
186
180
|
- test/files/iso-8859-2.html
|
@@ -206,17 +200,17 @@ require_paths:
|
|
206
200
|
- lib
|
207
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
208
202
|
requirements:
|
209
|
-
- -
|
203
|
+
- - ">="
|
210
204
|
- !ruby/object:Gem::Version
|
211
205
|
version: '0'
|
212
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
207
|
requirements:
|
214
|
-
- -
|
208
|
+
- - ">="
|
215
209
|
- !ruby/object:Gem::Version
|
216
210
|
version: '0'
|
217
211
|
requirements: []
|
218
212
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.4.3
|
220
214
|
signing_key:
|
221
215
|
specification_version: 4
|
222
216
|
summary: Preflight for HTML e-mail.
|
@@ -229,6 +223,8 @@ test_files:
|
|
229
223
|
- test/files/dots_h.gif
|
230
224
|
- test/files/html4.html
|
231
225
|
- test/files/html_with_uri.html
|
226
|
+
- test/files/ignore.css
|
227
|
+
- test/files/ignore.html
|
232
228
|
- test/files/import.css
|
233
229
|
- test/files/inc/2009-placeholder.png
|
234
230
|
- test/files/iso-8859-2.html
|