premailer 1.13.1 → 1.14.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: c8c65984e17019ce303019a4c1798c6be9b265307739b9961615a0e5f80a456f
4
- data.tar.gz: 209a139c10aa4f8c22783e6ec05019509fd59eddb72803f2e9ab5b484a640918
3
+ metadata.gz: 7b0c26667a2941fae4ad03348359e5bc395d6f80bb411ea8a79a7f206e22804d
4
+ data.tar.gz: f204d04b9480c0ae14853013ee7f7aa561dce207109bfa07275331d1c6e88434
5
5
  SHA512:
6
- metadata.gz: 8dc2084696422cc0fb04b1aef915040bf91295662bbf25d12b0a0b0f1235d94ad0b2c6d8794f60a7d8a218dbec5335176504f7bc31f700fa836fa021e4c19ac0
7
- data.tar.gz: dee28c3dfc8642e0a47446a1bf9790fbd0bce56c41069f585f1bb51b762e8f001597dd1a547efaaff95648093ea6ce36db5421d99ed947c1e9a5908fa123d688
6
+ metadata.gz: 8a3ab8546bdffd65325f5f564659dcb2a8ed9d93a8060c5b5fffdc14db08e719de1902f33e1495fd83777996e198d1ea53fee54e267423d5c5ac9ddacbb81755
7
+ data.tar.gz: 3252d5e22b3f553a9d73b55bc61e1609b6172a1710893871d96abd8a94891a5e1a7e562fb2f623946bf3897f73444bbed692815c908a764dbc0f108ce989dc84
data/README.md CHANGED
@@ -68,7 +68,7 @@ Premailer::Adapter.use = :nokogiri_fast
68
68
 
69
69
  ## Ruby Compatibility
70
70
 
71
- Premailer is tested on Ruby 2.1 and above. JRuby support is close; contributors are welcome. Checkout the latest build status on the [Travis CI dashboard](https://travis-ci.org/#!/premailer/premailer).
71
+ See .travis.yml for which ruby versions are tested. JRuby support is close, contributors are welcome. Checkout the latest build status on the [Travis CI dashboard](https://travis-ci.org/#!/premailer/premailer).
72
72
 
73
73
  ## Premailer-specific CSS
74
74
 
@@ -55,9 +55,7 @@ class Premailer
55
55
  end
56
56
 
57
57
  # Remove script tags
58
- if @options[:remove_scripts]
59
- doc.search("script").remove
60
- end
58
+ doc.search("script").remove if @options[:remove_scripts]
61
59
 
62
60
  # Read STYLE attributes and perform folding
63
61
  doc.search("*[@style]").each do |el|
@@ -75,18 +73,33 @@ class Premailer
75
73
 
76
74
  # Duplicate CSS attributes as HTML attributes
77
75
  if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
78
- Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
79
- if el[html_att].nil? and not merged[css_att].empty?
80
- new_html_att = merged[css_att].gsub(/url\(['"](.*)['"]\)/, '\1').gsub(/;$|\s*!important/, '').strip
81
- el[html_att] = css_att.end_with?('color') && @options[:rgb_to_hex_attributes] ? ensure_hex(new_html_att) : new_html_att
76
+ Premailer::RELATED_ATTRIBUTES[el.name].each do |css_attr, html_attr|
77
+ if el[html_attr].nil? and not merged[css_attr].empty?
78
+ new_val = merged[css_attr].dup
79
+
80
+ # Remove url() function wrapper
81
+ new_val.gsub!(/url\(['"](.*)['"]\)/, '\1')
82
+
83
+ # Remove !important, trailing semi-colon, and leading/trailing whitespace
84
+ new_val.gsub!(/;$|\s*!important/, '').strip!
85
+
86
+ # For width and height tags, remove px units
87
+ new_val.gsub!(/(\d+)px/, '\1') if %w[width height].include?(html_attr)
88
+
89
+ # For color-related tags, convert RGB to hex if specified by options
90
+ new_val = ensure_hex(new_val) if css_attr.end_with?('color') && @options[:rgb_to_hex_attributes]
91
+
92
+ el[html_attr] = new_val
82
93
  end
94
+
83
95
  unless @options[:preserve_style_attribute]
84
96
  merged.instance_variable_get("@declarations").tap do |declarations|
85
- declarations.delete(css_att)
97
+ declarations.delete(css_attr)
86
98
  end
87
99
  end
88
100
  end
89
101
  end
102
+
90
103
  # Collapse multiple rules into one as much as possible.
91
104
  merged.create_shorthand! if @options[:create_shorthands]
92
105
 
@@ -77,18 +77,33 @@ class Premailer
77
77
 
78
78
  # Duplicate CSS attributes as HTML attributes
79
79
  if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
80
- Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
81
- if el[html_att].nil? and not merged[css_att].empty?
82
- new_html_att = merged[css_att].gsub(/url\(['"](.*)['"]\)/, '\1').gsub(/;$|\s*!important/, '').strip
83
- el[html_att] = css_att.end_with?('color') && @options[:rgb_to_hex_attributes] ? ensure_hex(new_html_att) : new_html_att
80
+ Premailer::RELATED_ATTRIBUTES[el.name].each do |css_attr, html_attr|
81
+ if el[html_attr].nil? and not merged[css_attr].empty?
82
+ new_val = merged[css_attr].dup
83
+
84
+ # Remove url() function wrapper
85
+ new_val.gsub!(/url\(['"](.*)['"]\)/, '\1')
86
+
87
+ # Remove !important, trailing semi-colon, and leading/trailing whitespace
88
+ new_val.gsub!(/;$|\s*!important/, '').strip!
89
+
90
+ # For width and height tags, remove px units
91
+ new_val.gsub!(/(\d+)px/, '\1') if %w[width height].include?(html_attr)
92
+
93
+ # For color-related tags, convert RGB to hex if specified by options
94
+ new_val = ensure_hex(new_val) if css_attr.end_with?('color') && @options[:rgb_to_hex_attributes]
95
+
96
+ el[html_attr] = new_val
84
97
  end
98
+
85
99
  unless @options[:preserve_style_attribute]
86
100
  merged.instance_variable_get("@declarations").tap do |declarations|
87
- declarations.delete(css_att)
101
+ declarations.delete(css_attr)
88
102
  end
89
103
  end
90
104
  end
91
105
  end
106
+
92
107
  # Collapse multiple rules into one as much as possible.
93
108
  merged.create_shorthand! if @options[:create_shorthands]
94
109
 
@@ -55,9 +55,7 @@ class Premailer
55
55
  end
56
56
 
57
57
  # Remove script tags
58
- if @options[:remove_scripts]
59
- doc.search("script").remove
60
- end
58
+ doc.search("script").remove if @options[:remove_scripts]
61
59
 
62
60
  # Read STYLE attributes and perform folding
63
61
  doc.search("*[@style]").each do |el|
@@ -75,18 +73,33 @@ class Premailer
75
73
 
76
74
  # Duplicate CSS attributes as HTML attributes
77
75
  if Premailer::RELATED_ATTRIBUTES.has_key?(el.name) && @options[:css_to_attributes]
78
- Premailer::RELATED_ATTRIBUTES[el.name].each do |css_att, html_att|
79
- if el[html_att].nil? and not merged[css_att].empty?
80
- new_html_att = merged[css_att].gsub(/url\(['"](.*)['"]\)/, '\1').gsub(/;$|\s*!important/, '').strip
81
- el[html_att] = css_att.end_with?('color') && @options[:rgb_to_hex_attributes] ? ensure_hex(new_html_att) : new_html_att
76
+ Premailer::RELATED_ATTRIBUTES[el.name].each do |css_attr, html_attr|
77
+ if el[html_attr].nil? and not merged[css_attr].empty?
78
+ new_val = merged[css_attr].dup
79
+
80
+ # Remove url() function wrapper
81
+ new_val.gsub!(/url\(['"](.*)['"]\)/, '\1')
82
+
83
+ # Remove !important, trailing semi-colon, and leading/trailing whitespace
84
+ new_val.gsub!(/;$|\s*!important/, '').strip!
85
+
86
+ # For width and height tags, remove px units
87
+ new_val.gsub!(/(\d+)px/, '\1') if %w[width height].include?(html_attr)
88
+
89
+ # For color-related tags, convert RGB to hex if specified by options
90
+ new_val = ensure_hex(new_val) if css_attr.end_with?('color') && @options[:rgb_to_hex_attributes]
91
+
92
+ el[html_attr] = new_val
82
93
  end
94
+
83
95
  unless @options[:preserve_style_attribute]
84
96
  merged.instance_variable_get("@declarations").tap do |declarations|
85
- declarations.delete(css_att)
97
+ declarations.delete(css_attr)
86
98
  end
87
99
  end
88
100
  end
89
101
  end
102
+
90
103
  # Collapse multiple rules into one as much as possible.
91
104
  merged.create_shorthand! if @options[:create_shorthands]
92
105
 
@@ -1,4 +1,4 @@
1
1
  class Premailer
2
2
  # Premailer version.
3
- VERSION = '1.13.1'.freeze
3
+ VERSION = '1.14.1'.freeze
4
4
  end
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.13.1
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser