premailer 1.20.0 → 1.22.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/lib/premailer/adapter/nokogiri.rb +6 -8
- data/lib/premailer/adapter/nokogiri_fast.rb +11 -3
- data/lib/premailer/adapter/nokogumbo.rb +11 -3
- data/lib/premailer/cached_rule_set.rb +12 -0
- data/lib/premailer/version.rb +1 -1
- data/lib/premailer.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f373e83545e1f1b1ca346a0bfcfe2fa79daf3b0b64e71f2b346e19421495669c
|
4
|
+
data.tar.gz: ba3eb857e1fd0c956489566776b8f911a8da10372aad4932c89fb7c6c0e65d68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba181a7933d0281f01de3b91956282d15b5958ca544e57ed9dc7a79923140f4e6b9c873ee77cd1e84060db624194cbf33cf90078395e66edea714d1ca30d2653
|
7
|
+
data.tar.gz: 7e61434faf7ed25db77f310fb9adc322322deb0dacfc5ec763645920f0d3c51ebefe50dddc58a2591dce99415cc9da7a4fa9b4b484289a1e6934ebdb143a8b14
|
@@ -61,14 +61,12 @@ class Premailer
|
|
61
61
|
doc.search("*[@style]").each do |el|
|
62
62
|
style = el.attributes['style'].to_s
|
63
63
|
|
64
|
-
declarations = []
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
raise e if @options[:rule_set_exceptions]
|
71
|
-
end
|
64
|
+
declarations = style.scan(/\[SPEC\=([\d]+)\[(.[^\]\]]*)\]\]/).filter_map do |declaration|
|
65
|
+
rs = Premailer::CachedRuleSet.new(nil, declaration[1].to_s, declaration[0].to_i)
|
66
|
+
rs.expand_shorthand!
|
67
|
+
rs
|
68
|
+
rescue ArgumentError => e
|
69
|
+
raise e if @options[:rule_set_exceptions]
|
72
70
|
end
|
73
71
|
|
74
72
|
# Perform style folding
|
@@ -67,13 +67,21 @@ class Premailer
|
|
67
67
|
|
68
68
|
declarations = []
|
69
69
|
style.scan(/\[SPEC\=([\d]+)\[(.[^\]\]]*)\]\]/).each do |declaration|
|
70
|
-
|
71
|
-
|
70
|
+
begin
|
71
|
+
rs = CssParser::RuleSet.new(nil, declaration[1].to_s, declaration[0].to_i)
|
72
|
+
declarations << rs
|
73
|
+
rescue ArgumentError => e
|
74
|
+
raise e if @options[:rule_set_exceptions]
|
75
|
+
end
|
72
76
|
end
|
73
77
|
|
74
78
|
# Perform style folding
|
75
79
|
merged = CssParser.merge(declarations)
|
76
|
-
|
80
|
+
begin
|
81
|
+
merged.expand_shorthand!
|
82
|
+
rescue ArgumentError => e
|
83
|
+
raise e if @options[:rule_set_exceptions]
|
84
|
+
end
|
77
85
|
|
78
86
|
# Duplicate CSS attributes as HTML attributes
|
79
87
|
if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
|
@@ -61,13 +61,21 @@ class Premailer
|
|
61
61
|
|
62
62
|
declarations = []
|
63
63
|
style.scan(/\[SPEC\=([\d]+)\[(.[^\]\]]*)\]\]/).each do |declaration|
|
64
|
-
|
65
|
-
|
64
|
+
begin
|
65
|
+
rs = CssParser::RuleSet.new(nil, declaration[1].to_s, declaration[0].to_i)
|
66
|
+
declarations << rs
|
67
|
+
rescue ArgumentError => e
|
68
|
+
raise e if @options[:rule_set_exceptions]
|
69
|
+
end
|
66
70
|
end
|
67
71
|
|
68
72
|
# Perform style folding
|
69
73
|
merged = CssParser.merge(declarations)
|
70
|
-
|
74
|
+
begin
|
75
|
+
merged.expand_shorthand!
|
76
|
+
rescue ArgumentError => e
|
77
|
+
raise e if @options[:rule_set_exceptions]
|
78
|
+
end
|
71
79
|
|
72
80
|
# Duplicate CSS attributes as HTML attributes
|
73
81
|
if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Premailer
|
2
|
+
class CachedRuleSet < CssParser::RuleSet
|
3
|
+
# we call this early to find errors but css-parser calls it in .merge again
|
4
|
+
# so to prevent slowdown and bugs we refuse to run it twice on the same ruleset
|
5
|
+
# ideally should be upstreamed into css-parser
|
6
|
+
def expand_shorthand!
|
7
|
+
super unless @expand_shorthand
|
8
|
+
ensure
|
9
|
+
@expand_shorthand = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
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.22.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: 2023-
|
11
|
+
date: 2023-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: css_parser
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/premailer/adapter/nokogiri_fast.rb
|
188
188
|
- lib/premailer/adapter/nokogumbo.rb
|
189
189
|
- lib/premailer/adapter/rgb_to_hex.rb
|
190
|
+
- lib/premailer/cached_rule_set.rb
|
190
191
|
- lib/premailer/executor.rb
|
191
192
|
- lib/premailer/html_to_plain_text.rb
|
192
193
|
- lib/premailer/premailer.rb
|