premailer 1.8.6 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/bin/premailer +0 -1
- data/lib/premailer/adapter.rb +6 -2
- data/lib/premailer/adapter/hpricot.rb +12 -2
- data/lib/premailer/adapter/nokogiri.rb +8 -6
- data/lib/premailer/adapter/nokogumbo.rb +243 -0
- data/lib/premailer/html_to_plain_text.rb +9 -15
- data/lib/premailer/premailer.rb +11 -10
- data/lib/premailer/version.rb +1 -1
- metadata +64 -69
- data/.gitignore +0 -12
- data/.jrubyrc +0 -1
- data/.travis.yml +0 -34
- data/.yardopts +0 -9
- data/Gemfile +0 -16
- data/gemfiles/.ruby187.gemfile +0 -21
- data/init.rb +0 -1
- data/local-premailer +0 -9
- data/premailer.gemspec +0 -30
- data/rakefile.rb +0 -62
- data/test/files/base.html +0 -140
- data/test/files/chars.html +0 -6
- data/test/files/contact_bg.png +0 -0
- data/test/files/dialect.png +0 -0
- data/test/files/dots_end.png +0 -0
- data/test/files/dots_h.gif +0 -0
- data/test/files/html4.html +0 -12
- data/test/files/html_with_uri.html +0 -9
- data/test/files/ignore.css +0 -3
- data/test/files/ignore.html +0 -15
- data/test/files/import.css +0 -13
- data/test/files/inc/2009-placeholder.png +0 -0
- data/test/files/iso-8859-2.html +0 -1
- data/test/files/iso-8859-5.html +0 -8
- data/test/files/no_css.html +0 -11
- data/test/files/noimport.css +0 -13
- data/test/files/styles.css +0 -106
- data/test/files/xhtml.html +0 -11
- data/test/future_tests.rb +0 -50
- data/test/helper.rb +0 -42
- data/test/test_adapter.rb +0 -29
- data/test/test_html_to_plain_text.rb +0 -184
- data/test/test_links.rb +0 -207
- data/test/test_misc.rb +0 -373
- data/test/test_premailer.rb +0 -347
- data/test/test_warnings.rb +0 -95
data/test/test_links.rb
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__)) + '/helper'
|
3
|
-
|
4
|
-
class TestLinks < Premailer::TestCase
|
5
|
-
def test_empty_query_string
|
6
|
-
assert_nothing_raised do
|
7
|
-
premailer = Premailer.new('<p>Test</p>', :with_html_string => true, :link_query_string => ' ')
|
8
|
-
premailer.to_inline_css
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_appending_link_query_string
|
13
|
-
qs = 'utm_source=1234&tracking=good&doublescape'
|
14
|
-
opts = {:base_url => 'http://example.com/', :link_query_string => qs, :with_html_string => true, :adapter => :hpricot}
|
15
|
-
|
16
|
-
appendable = [
|
17
|
-
'/',
|
18
|
-
opts[:base_url],
|
19
|
-
'https://example.com/tester',
|
20
|
-
'images/',
|
21
|
-
"#{opts[:base_url]}test.html?cn=tf&c=20&ord=random",
|
22
|
-
'?query=string'
|
23
|
-
]
|
24
|
-
|
25
|
-
not_appendable = [
|
26
|
-
'%DONOTCONVERT%',
|
27
|
-
'{DONOTCONVERT}',
|
28
|
-
'[DONOTCONVERT]',
|
29
|
-
'<DONOTCONVERT>',
|
30
|
-
'{@msg-txturl}',
|
31
|
-
'[[!unsubscribe]]',
|
32
|
-
'#relative',
|
33
|
-
'tel:5555551212',
|
34
|
-
'http://example.net/',
|
35
|
-
'mailto:premailer@example.com',
|
36
|
-
'ftp://example.com',
|
37
|
-
'gopher://gopher.floodgap.com/1/fun/twitpher'
|
38
|
-
]
|
39
|
-
|
40
|
-
html = appendable.collect {|url| "<a href='#{url}'>Link</a>" }
|
41
|
-
|
42
|
-
premailer = Premailer.new(html.to_s, opts)
|
43
|
-
premailer.to_inline_css
|
44
|
-
|
45
|
-
premailer.processed_doc.search('a').each do |el|
|
46
|
-
href = el.attributes['href'].to_s
|
47
|
-
next if href.nil? or href.empty?
|
48
|
-
uri = URI.parse(href)
|
49
|
-
assert_match qs, uri.query, "missing query string for #{el.to_s}"
|
50
|
-
end
|
51
|
-
|
52
|
-
html = not_appendable.collect {|url| "<a href='#{url}'>Link</a>" }
|
53
|
-
|
54
|
-
premailer = Premailer.new(html.to_s, opts)
|
55
|
-
premailer.to_inline_css
|
56
|
-
|
57
|
-
premailer.processed_doc.search('a').each do |el|
|
58
|
-
href = el['href']
|
59
|
-
next if href.nil? or href.empty?
|
60
|
-
assert not_appendable.include?(href), "link #{href} should not be converted: see #{not_appendable.to_s}"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_stripping_extra_question_marks_from_query_string
|
65
|
-
qs = '??utm_source=1234'
|
66
|
-
|
67
|
-
premailer = Premailer.new("<a href='/test/?'>Link</a> <a href='/test/'>Link</a>", :link_query_string => qs, :with_html_string => true)
|
68
|
-
premailer.to_inline_css
|
69
|
-
|
70
|
-
premailer.processed_doc.search('a').each do |a|
|
71
|
-
assert_equal '/test/?utm_source=1234', a['href'].to_s
|
72
|
-
end
|
73
|
-
|
74
|
-
premailer = Premailer.new("<a href='/test/?123&456'>Link</a>", :link_query_string => qs, :with_html_string => true)
|
75
|
-
premailer.to_inline_css
|
76
|
-
|
77
|
-
assert_equal '/test/?123&456&utm_source=1234', premailer.processed_doc.at('a')['href']
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_unescape_ampersand
|
81
|
-
qs = 'utm_source=1234'
|
82
|
-
|
83
|
-
premailer = Premailer.new("<a href='/test/?q=query'>Link</a>", :link_query_string => qs, :with_html_string => true, :unescaped_ampersand => true)
|
84
|
-
premailer.to_inline_css
|
85
|
-
|
86
|
-
premailer.processed_doc.search('a').each do |a|
|
87
|
-
assert_equal '/test/?q=query&utm_source=1234', a['href'].to_s
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_preserving_links
|
92
|
-
html = "<a href='http://example.com/index.php?pram1=one&pram2=two'>Link</a>"
|
93
|
-
premailer = Premailer.new(html.to_s, :link_query_string => '', :with_html_string => true)
|
94
|
-
premailer.to_inline_css
|
95
|
-
|
96
|
-
assert_equal 'http://example.com/index.php?pram1=one&pram2=two', premailer.processed_doc.at('a')['href']
|
97
|
-
|
98
|
-
html = "<a href='http://example.com/index.php?pram1=one&pram2=two'>Link</a>"
|
99
|
-
premailer = Premailer.new(html.to_s, :link_query_string => 'qs', :with_html_string => true)
|
100
|
-
premailer.to_inline_css
|
101
|
-
|
102
|
-
assert_equal 'http://example.com/index.php?pram1=one&pram2=two&qs', premailer.processed_doc.at('a')['href']
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_resolving_urls_from_string
|
107
|
-
['test.html', '/test.html', './test.html',
|
108
|
-
'test/../test.html', 'test/../test/../test.html'].each do |q|
|
109
|
-
assert_equal 'http://example.com/test.html', Premailer.resolve_link(q, 'http://example.com/'), q
|
110
|
-
end
|
111
|
-
|
112
|
-
assert_equal 'https://example.net:80/~basedir/test.html?var=1#anchor', Premailer.resolve_link('test/../test/../test.html?var=1#anchor', 'https://example.net:80/~basedir/')
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_resolving_urls_from_uri
|
116
|
-
base_uri = URI.parse('http://example.com/')
|
117
|
-
['test.html', '/test.html', './test.html',
|
118
|
-
'test/../test.html', 'test/../test/../test.html'].each do |q|
|
119
|
-
assert_equal 'http://example.com/test.html', Premailer.resolve_link(q, base_uri), q
|
120
|
-
end
|
121
|
-
|
122
|
-
base_uri = URI.parse('https://example.net:80/~basedir/')
|
123
|
-
assert_equal 'https://example.net:80/~basedir/test.html?var=1#anchor', Premailer.resolve_link('test/../test/../test.html?var=1#anchor', base_uri)
|
124
|
-
|
125
|
-
# base URI with a query string
|
126
|
-
base_uri = URI.parse('http://example.com/dir/index.cfm?newsletterID=16')
|
127
|
-
assert_equal 'http://example.com/dir/index.cfm?link=15', Premailer.resolve_link('?link=15', base_uri)
|
128
|
-
|
129
|
-
# URI preceded by a space
|
130
|
-
base_uri = URI.parse('http://example.com/')
|
131
|
-
assert_equal 'http://example.com/path', Premailer.resolve_link(' path', base_uri)
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_resolving_urls_from_html_string
|
135
|
-
# The inner URI is on its own line to ensure that the impl doesn't match
|
136
|
-
# URIs based on start of line.
|
137
|
-
base_uri = "<html><head></head><body>\nhttp://example.com/\n</body>"
|
138
|
-
['test.html', '/test.html', './test.html',
|
139
|
-
'test/../test.html', 'test/../test/../test.html'].each do |q|
|
140
|
-
assert_nothing_raised do
|
141
|
-
Premailer.resolve_link(q, base_uri)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_resolving_urls_in_doc
|
147
|
-
# force Nokogiri since this consistenly segfaults with Hpricot
|
148
|
-
base_file = File.dirname(__FILE__) + '/files/base.html'
|
149
|
-
base_url = 'https://my.example.com:8080/test-path.html'
|
150
|
-
premailer = Premailer.new(base_file, :base_url => base_url, :adapter => :nokogiri)
|
151
|
-
premailer.to_inline_css
|
152
|
-
pdoc = premailer.processed_doc
|
153
|
-
doc = premailer.doc
|
154
|
-
|
155
|
-
# unchanged links
|
156
|
-
['#l02', '#l03', '#l05', '#l06', '#l07', '#l08',
|
157
|
-
'#l09', '#l10', '#l11', '#l12', '#l13'].each do |link_id|
|
158
|
-
assert_equal doc.at(link_id).attributes['href'], pdoc.at(link_id).attributes['href'], link_id
|
159
|
-
end
|
160
|
-
|
161
|
-
assert_equal 'https://my.example.com:8080/', pdoc.at('#l01').attributes['href'].to_s
|
162
|
-
assert_equal 'https://my.example.com:8080/images/', pdoc.at('#l04').attributes['href'].to_s
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_convertable_inline_links
|
166
|
-
convertable = [
|
167
|
-
'my/path/to',
|
168
|
-
'other/path',
|
169
|
-
'/'
|
170
|
-
]
|
171
|
-
|
172
|
-
html = convertable.collect {|url| "<a href='#{url}'>Link</a>" }
|
173
|
-
premailer = Premailer.new(html.to_s, :base_url => "http://example.com", :with_html_string => true)
|
174
|
-
|
175
|
-
premailer.processed_doc.search('a').each do |el|
|
176
|
-
href = el.attributes['href'].to_s
|
177
|
-
assert(href =~ /http:\/\/example.com/, "link #{href} is not absolute")
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_non_convertable_inline_links
|
182
|
-
not_convertable = [
|
183
|
-
'%DONOTCONVERT%',
|
184
|
-
'{DONOTCONVERT}',
|
185
|
-
'[DONOTCONVERT]',
|
186
|
-
'<DONOTCONVERT>',
|
187
|
-
'{@msg-txturl}',
|
188
|
-
'[[!unsubscribe]]',
|
189
|
-
'#relative',
|
190
|
-
'tel:5555551212',
|
191
|
-
'mailto:premailer@example.com',
|
192
|
-
'ftp://example.com',
|
193
|
-
'gopher://gopher.floodgap.com/1/fun/twitpher',
|
194
|
-
'cid:13443452066.10392logo.jpeg@inline_attachment'
|
195
|
-
]
|
196
|
-
|
197
|
-
html = not_convertable.collect {|url| "<a href='#{url}'>Link</a>" }
|
198
|
-
|
199
|
-
premailer = Premailer.new(html.to_s, :base_url => "example.com", :with_html_string => true)
|
200
|
-
premailer.to_inline_css
|
201
|
-
|
202
|
-
premailer.processed_doc.search('a').each do |el|
|
203
|
-
href = el.attributes['href'].to_s
|
204
|
-
assert not_convertable.include?(href), "link #{href} should not be converted: see #{not_convertable.inspect}"
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
data/test/test_misc.rb
DELETED
@@ -1,373 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require File.expand_path(File.dirname(__FILE__)) + '/helper'
|
3
|
-
|
4
|
-
# Random tests for specific issues.
|
5
|
-
#
|
6
|
-
# The test suite will be cleaned up at some point soon.
|
7
|
-
class TestMisc < Premailer::TestCase
|
8
|
-
|
9
|
-
# in response to http://github.com/alexdunae/premailer/issues#issue/4
|
10
|
-
#
|
11
|
-
# NB: 2010-11-16 -- after reverting to Hpricot this test can no longer pass.
|
12
|
-
# It's too much of an edge case to get any dev time.
|
13
|
-
def test_parsing_extra_quotes
|
14
|
-
io = StringIO.new('<p></p>
|
15
|
-
<h3 "id="WAR"><a name="WAR"></a>Writes and Resources</h3>
|
16
|
-
<table></table>')
|
17
|
-
premailer = Premailer.new(io, :adapter => :nokogiri)
|
18
|
-
assert_match /<h3>[\s]*<a name="WAR">[\s]*<\/a>[\s]*Writes and Resources[\s]*<\/h3>/i, premailer.to_inline_css
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_styles_in_the_body
|
22
|
-
html = <<END_HTML
|
23
|
-
<html>
|
24
|
-
<body>
|
25
|
-
<style type="text/css"> p { color: red; } </style>
|
26
|
-
<p>Test</p>
|
27
|
-
</body>
|
28
|
-
</html>
|
29
|
-
END_HTML
|
30
|
-
|
31
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
32
|
-
premailer.to_inline_css
|
33
|
-
|
34
|
-
assert_match /color\: red/i, premailer.processed_doc.at('p')['style']
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_commented_out_styles_in_the_body
|
38
|
-
html = <<END_HTML
|
39
|
-
<html>
|
40
|
-
<body>
|
41
|
-
<style type="text/css"> <!-- p { color: red; } --> </style>
|
42
|
-
<p>Test</p>
|
43
|
-
</body>
|
44
|
-
</html>
|
45
|
-
END_HTML
|
46
|
-
|
47
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
48
|
-
premailer.to_inline_css
|
49
|
-
|
50
|
-
assert_match /color\: red/i, premailer.processed_doc.at('p')['style']
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_not_applying_styles_to_the_head
|
54
|
-
html = <<END_HTML
|
55
|
-
<html>
|
56
|
-
<head>
|
57
|
-
<title>Title</title>
|
58
|
-
<style type="text/css"> * { color: red; } </style>
|
59
|
-
</head>
|
60
|
-
<body>
|
61
|
-
<p><a>Test</a></p>
|
62
|
-
</body>
|
63
|
-
</html>
|
64
|
-
END_HTML
|
65
|
-
|
66
|
-
[:nokogiri, :hpricot].each do |adapter|
|
67
|
-
premailer = Premailer.new(html, :with_html_string => true, :adapter => adapter)
|
68
|
-
premailer.to_inline_css
|
69
|
-
|
70
|
-
h = premailer.processed_doc.at('head')
|
71
|
-
assert_nil h['style']
|
72
|
-
|
73
|
-
t = premailer.processed_doc.at('title')
|
74
|
-
assert_nil t['style']
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_multiple_identical_ids
|
79
|
-
html = <<-END_HTML
|
80
|
-
<html>
|
81
|
-
<head>
|
82
|
-
<style type="text/css"> #the_id { color: red; } </style>
|
83
|
-
</head>
|
84
|
-
<body>
|
85
|
-
<p id="the_id">Test</p>
|
86
|
-
<p id="the_id">Test</p>
|
87
|
-
</body>
|
88
|
-
</html>
|
89
|
-
END_HTML
|
90
|
-
|
91
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
92
|
-
premailer.to_inline_css
|
93
|
-
premailer.processed_doc.search('p').each do |el|
|
94
|
-
assert_match /red/i, el['style']
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_preserving_styles
|
99
|
-
html = <<END_HTML
|
100
|
-
<html>
|
101
|
-
<head>
|
102
|
-
<link rel="stylesheet" href="#"/>
|
103
|
-
<style type="text/css"> a:hover { color: red; } </style>
|
104
|
-
</head>
|
105
|
-
<body>
|
106
|
-
<p><a>Test</a></p>
|
107
|
-
</body>
|
108
|
-
</html>
|
109
|
-
END_HTML
|
110
|
-
[:nokogiri, :hpricot].each do |adapter|
|
111
|
-
premailer = Premailer.new(html, :with_html_string => true, :preserve_styles => true, :adapter => adapter)
|
112
|
-
premailer.to_inline_css
|
113
|
-
assert_equal 1, premailer.processed_doc.search('head link').length
|
114
|
-
assert_equal 1, premailer.processed_doc.search('head style').length
|
115
|
-
|
116
|
-
premailer = Premailer.new(html, :with_html_string => true, :preserve_styles => false, :adapter => adapter)
|
117
|
-
premailer.to_inline_css
|
118
|
-
assert_nil premailer.processed_doc.at('body link')
|
119
|
-
|
120
|
-
# should be preserved as unmergeable
|
121
|
-
|
122
|
-
assert_match /color: red/i, premailer.processed_doc.at('body style').inner_html
|
123
|
-
|
124
|
-
assert_match /a:hover/i, premailer.processed_doc.at('style').inner_html
|
125
|
-
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_unmergable_rules
|
130
|
-
html = <<END_HTML
|
131
|
-
<html> <head> <style type="text/css"> a { color:blue; } a:hover { color: red; } </style> </head>
|
132
|
-
<p><a>Test</a></p>
|
133
|
-
</body> </html>
|
134
|
-
END_HTML
|
135
|
-
|
136
|
-
premailer = Premailer.new(html, :with_html_string => true, :verbose => true)
|
137
|
-
premailer.to_inline_css
|
138
|
-
|
139
|
-
# blue should be inlined
|
140
|
-
assert_no_match /a\:hover[\s]*\{[\s]*color\:[\s]*blue[\s]*;[\s]*\}/i, premailer.processed_doc.at('body style').inner_html
|
141
|
-
# red should remain in <style> block
|
142
|
-
assert_match /a\:hover[\s]*\{[\s]*color\:[\s]*red;[\s]*\}/i, premailer.processed_doc.at('body style').inner_html
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_unmergable_media_queries
|
146
|
-
html = <<END_HTML
|
147
|
-
<html> <head>
|
148
|
-
<style type="text/css">
|
149
|
-
a { color: blue; }
|
150
|
-
@media (min-width:500px) {
|
151
|
-
a { color: red; }
|
152
|
-
}
|
153
|
-
@media screen and (orientation: portrait) {
|
154
|
-
a { color: green; }
|
155
|
-
}
|
156
|
-
</style>
|
157
|
-
</head>
|
158
|
-
<body>
|
159
|
-
<p><a>Test</a></p>
|
160
|
-
</body> </html>
|
161
|
-
END_HTML
|
162
|
-
|
163
|
-
[:nokogiri, :hpricot].each do |adapter|
|
164
|
-
puts "------- Testing adapter #{adapter}"
|
165
|
-
premailer = Premailer.new(html, :with_html_string => true, :adapter => adapter)
|
166
|
-
puts premailer.to_inline_css
|
167
|
-
|
168
|
-
style_tag = premailer.processed_doc.at('body style')
|
169
|
-
assert style_tag, "#{adapter} failed to add a body style tag"
|
170
|
-
|
171
|
-
style_tag_contents = style_tag.inner_html
|
172
|
-
|
173
|
-
assert_equal "color: blue", premailer.processed_doc.at('a').attributes['style'].to_s,
|
174
|
-
"#{adapter}: Failed to inline the default style"
|
175
|
-
assert_match /@media \(min-width:500px\) \{.*?a \{.*?color: red;.*?\}.*?\}/m, style_tag_contents,
|
176
|
-
"#{adapter}: Failed to add media query with no type to style"
|
177
|
-
assert_match /@media screen and \(orientation: portrait\) \{.*?a \{.*?color: green;.*?\}.*?\}/m, style_tag_contents,
|
178
|
-
"#{adapter}: Failed to add media query with type to style"
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_unmergable_rules_with_no_body
|
184
|
-
html = <<END_HTML
|
185
|
-
<html>
|
186
|
-
<style type="text/css"> a:hover { color: red; } </style>
|
187
|
-
<p><a>Test</a></p>
|
188
|
-
</html>
|
189
|
-
END_HTML
|
190
|
-
|
191
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
192
|
-
assert_nothing_raised do
|
193
|
-
premailer.to_inline_css
|
194
|
-
end
|
195
|
-
assert_match /a\:hover[\s]*\{[\s]*color\:[\s]*red;[\s]*\}/i, premailer.processed_doc.at('style').inner_html
|
196
|
-
end
|
197
|
-
|
198
|
-
# in response to https://github.com/alexdunae/premailer/issues#issue/7
|
199
|
-
def test_ignoring_link_pseudo_selectors
|
200
|
-
html = <<END_HTML
|
201
|
-
<html>
|
202
|
-
<style type="text/css"> td a:link.top_links { color: red; } </style>
|
203
|
-
<body>
|
204
|
-
<td><a class="top_links">Test</a></td>
|
205
|
-
</body>
|
206
|
-
</html>
|
207
|
-
END_HTML
|
208
|
-
|
209
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
210
|
-
assert_nothing_raised do
|
211
|
-
premailer.to_inline_css
|
212
|
-
end
|
213
|
-
assert_match /color: red/, premailer.processed_doc.at('a').attributes['style'].to_s
|
214
|
-
end
|
215
|
-
|
216
|
-
# in response to https://github.com/alexdunae/premailer/issues#issue/7
|
217
|
-
#
|
218
|
-
# fails sometimes in JRuby, see https://github.com/alexdunae/premailer/issues/79
|
219
|
-
def test_parsing_bad_markup_around_tables
|
220
|
-
html = <<END_HTML
|
221
|
-
<html>
|
222
|
-
<style type="text/css">
|
223
|
-
.style3 { font-size: xx-large; }
|
224
|
-
.style5 { background-color: #000080; }
|
225
|
-
</style>
|
226
|
-
<tr>
|
227
|
-
<td valign="top" class="style3">
|
228
|
-
<!-- MSCellType="ContentHead" -->
|
229
|
-
<strong>PROMOCION CURSOS PRESENCIALES</strong></td>
|
230
|
-
<strong>
|
231
|
-
<td valign="top" style="height: 125px" class="style5">
|
232
|
-
<!-- MSCellType="DecArea" -->
|
233
|
-
<img alt="" src="../../images/CertisegGold.GIF" width="608" height="87" /></td>
|
234
|
-
</tr>
|
235
|
-
END_HTML
|
236
|
-
|
237
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
238
|
-
premailer.to_inline_css
|
239
|
-
assert_match /font-size: xx-large/, premailer.processed_doc.search('.style3').first.attributes['style'].to_s
|
240
|
-
assert_match /background: #000080/, premailer.processed_doc.search('.style5').first.attributes['style'].to_s
|
241
|
-
end
|
242
|
-
|
243
|
-
# in response to https://github.com/alexdunae/premailer/issues/56
|
244
|
-
def test_inline_important
|
245
|
-
html = <<END_HTML
|
246
|
-
<html>
|
247
|
-
<style type="text/css">
|
248
|
-
p { color: red !important; }
|
249
|
-
</style>
|
250
|
-
<body>
|
251
|
-
<p style='color: green !important;'>test</p></div>
|
252
|
-
</body>
|
253
|
-
</html>
|
254
|
-
END_HTML
|
255
|
-
|
256
|
-
premailer = Premailer.new(html, :with_html_string => true, :adapter => :nokogiri)
|
257
|
-
premailer.to_inline_css
|
258
|
-
assert_equal 'color: green !important', premailer.processed_doc.search('p').first.attributes['style'].to_s
|
259
|
-
end
|
260
|
-
|
261
|
-
# in response to https://github.com/alexdunae/premailer/issues/28
|
262
|
-
def test_handling_shorthand_auto_properties
|
263
|
-
html = <<END_HTML
|
264
|
-
<html>
|
265
|
-
<style type="text/css">
|
266
|
-
#page { margin: 0; margin-left: auto; margin-right: auto; }
|
267
|
-
p { border: 1px solid black; border-right: none; }
|
268
|
-
|
269
|
-
</style>
|
270
|
-
<body>
|
271
|
-
<div id='page'><p>test</p></div>
|
272
|
-
</body>
|
273
|
-
</html>
|
274
|
-
END_HTML
|
275
|
-
|
276
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
277
|
-
premailer.to_inline_css
|
278
|
-
|
279
|
-
assert_match /margin: 0 auto/, premailer.processed_doc.search('#page').first.attributes['style'].to_s
|
280
|
-
assert_match /border-style: solid none solid solid;/, premailer.processed_doc.search('p').first.attributes['style'].to_s
|
281
|
-
end
|
282
|
-
|
283
|
-
def test_sorting_style_attributes
|
284
|
-
html = <<END_HTML
|
285
|
-
<html>
|
286
|
-
<style type="text/css">
|
287
|
-
#page { right: 10px; left: 5px }
|
288
|
-
</style>
|
289
|
-
<body>
|
290
|
-
<div id='page'>test</div>
|
291
|
-
</body>
|
292
|
-
</html>
|
293
|
-
END_HTML
|
294
|
-
|
295
|
-
premailer = Premailer.new(html, :with_html_string => true)
|
296
|
-
premailer.to_inline_css
|
297
|
-
assert_equal "left: 5px; right: 10px", premailer.processed_doc.search('#page').first.attributes['style'].to_s
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_removing_scripts
|
301
|
-
html = <<END_HTML
|
302
|
-
<html>
|
303
|
-
<head>
|
304
|
-
<script>script to be removed</script>
|
305
|
-
</head>
|
306
|
-
<body>
|
307
|
-
content
|
308
|
-
</body>
|
309
|
-
</html>
|
310
|
-
END_HTML
|
311
|
-
|
312
|
-
[:nokogiri, :hpricot].each do |adapter|
|
313
|
-
premailer = Premailer.new(html, :with_html_string => true, :remove_scripts => true, :adapter => adapter)
|
314
|
-
premailer.to_inline_css
|
315
|
-
assert_equal 0, premailer.processed_doc.search('script').length
|
316
|
-
end
|
317
|
-
|
318
|
-
[:nokogiri, :hpricot].each do |adapter|
|
319
|
-
premailer = Premailer.new(html, :with_html_string => true, :remove_scripts => false, :adapter => adapter)
|
320
|
-
premailer.to_inline_css
|
321
|
-
assert_equal 1, premailer.processed_doc.search('script').length
|
322
|
-
end
|
323
|
-
end
|
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
|
373
|
-
end
|