premailer 1.14.3 → 1.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e62efcd15fd7c988efb25a7dc326adb7ffd4531bd3aabff7fe0de0a7099ab9e8
4
- data.tar.gz: 4cee57fc796dd4409c96b6ff5c067441d182a5e0a44604ed2b6b02836018d625
3
+ metadata.gz: 1cbcf7916881885f8da597bf060d93f4faa9a909051f3be3331d63c01b12d07f
4
+ data.tar.gz: 9f507ecec471e66009960367a42ffb618a6f9769fa3bc59358c40e9c0e676bd8
5
5
  SHA512:
6
- metadata.gz: b888135d71b9b96555264ec940bc06b19d86019e4a446751be02fcfd6d2bfc7862357edee3405b4076c23e701a5794767799a862133f7aef91fa650c5979db80
7
- data.tar.gz: a8f45e8985ef02a82825e29b24653351430ee3f8482696d276858ea3deaf423499a323fa897d19533b120fea9ab2a38be2bf1f229f41572f61745aa1f3e9c958
6
+ metadata.gz: 823f4d6c03aaa776cca778046154c5471312ffcd79296801f94b9cc8b06e5e5a5ca79e5a3f668b03e17fa72ec3419250388ce79c4ddf8cc800c6e9554b783b4b
7
+ data.tar.gz: 43ce39e4a1bc35a4e275072c64ee806b7bb8a735b40eafd67dc2da95671a6299ec9c6df0e35e2d6db86158245b8c9db6815fb96573953a452d95097fa760abe7
@@ -39,25 +39,21 @@ module HtmlToPlainText
39
39
  # remove script tags and content
40
40
  txt.gsub!(/<script.*?\/script>/m, '')
41
41
 
42
- # links with double quotes
43
- txt.gsub!(/<a\s[^\n]*?href=["'](mailto:)?([^"]*)["][^>]*>(.*?)<\/a>/im) do |s|
44
- if $3.empty?
45
- ''
46
- elsif $3.strip.downcase == $2.strip.downcase
47
- $3.strip
48
- else
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
- # links with single quotes
54
- txt.gsub!(/<a\s[^\n]*?href=["'](mailto:)?([^']*)['][^>]*>(.*?)<\/a>/im) do |s|
55
- if $3.empty?
51
+ if text.empty?
56
52
  ''
57
- elsif $3.strip.downcase == $2.strip.downcase
58
- $3.strip
53
+ elsif href.nil? || text.strip.downcase == href.strip.downcase
54
+ text.strip
59
55
  else
60
- $3.strip + ' ( ' + $2.strip + ' )'
56
+ text.strip + ' ( ' + href.strip + ' )'
61
57
  end
62
58
  end
63
59
 
@@ -1,4 +1,4 @@
1
1
  class Premailer
2
2
  # Premailer version.
3
- VERSION = '1.14.3'.freeze
3
+ VERSION = '1.15.0'.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.14.3
4
+ version: 1.15.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: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser