premailer 1.12.0 → 1.12.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: 6d3e8552d269ddef67b722b192f58c2afe242f6a824a07e4e7fd4e5bbc3f57f2
4
- data.tar.gz: 6c6b611237ffe68b655654c75c21c7a8f17bc73ca9502e06891f26ab5b1bb583
3
+ metadata.gz: 3b01f24d73b41f4214ef8ca3b2a1985fe73f52c51b08fd0556ff11b8efda5122
4
+ data.tar.gz: bc7cb36fe7064821e1ec20a529b3d1ea6f7e3f77495784bb9ce7b5983f6bea25
5
5
  SHA512:
6
- metadata.gz: 1c963172a6abcb9e71824c07e54a80ea89c58fda395349d68ea0567a5fa06cf160663bd1e8a169a81532f5ad3b7c97d8ed0ad2c09a4182c3d281982a878348da
7
- data.tar.gz: 758dae24fbd064a1ee44fe4ab6f0537c191826474dc045a8af5354f28a17e4d20e8a56e93d2ea3ebab83ab4c9c9b2376aa0b53467ff50338773e78e815b8ccbe
6
+ metadata.gz: 6ba7b88207293b27f1161ba1f684646b59d7783f334dcd28b562109662873423238c20a6a5b052815f890c05d9509b718c2e341ec6f7a04671a72e7b86bf7c46
7
+ data.tar.gz: 7544784edfb822d9d9c5cba949c554e9f208edfa5748567cc5a4a0455615cad3ce0aaed8b93e93235b7dc9e1b1a71c683d87bd317750fb20462fc161ff47294c
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Premailer README [![Build Status](https://travis-ci.org/premailer/premailer.png?branch=master)](https://travis-ci.org/premailer/premailer) [![Gem Version](https://badge.fury.io/rb/premailer.svg)](https://badge.fury.io/rb/premailer)
1
+ # Premailer README [![Build Status](https://travis-ci.org/premailer/premailer.svg?branch=master)](https://travis-ci.org/premailer/premailer) [![Gem Version](https://badge.fury.io/rb/premailer.svg)](https://badge.fury.io/rb/premailer)
2
2
 
3
3
  ## What is this?
4
4
 
@@ -97,6 +97,19 @@ will result in
97
97
  <table cellspacing='5' width='500'>
98
98
  ```
99
99
 
100
+ ## Configuration options
101
+
102
+ The behavior of Premailer can be configured by passing options in the initializer.
103
+
104
+ For example, the following will accept HTML from a string and will exclude unmergeable css from being added to the `<head>` of the output document.
105
+
106
+ ```ruby
107
+ premailer = Premailer.new(html_string, with_html_string: true, drop_unmergeable_css_rules: true)
108
+ ```
109
+
110
+ [See here for a full list of the available options](https://premailer.github.io/premailer/Premailer.html#initialize-instance_method).
111
+
112
+
100
113
  ## Contributions
101
114
 
102
115
  Contributions are most welcome. Premailer was rotting away in a private SVN repository for too long and could use some TLC. Fork and patch to your heart's content. Please don't increment the version numbers, though.
@@ -5,13 +5,14 @@ require 'htmlentities'
5
5
  module HtmlToPlainText
6
6
 
7
7
  # Returns the text in UTF-8 format with all HTML tags removed
8
- #
9
- # HTML content can be omitted from the output by surrounding it in the following comments:
8
+ #
9
+ # HTML content can be omitted from the output by surrounding it in the following comments:
10
10
  #
11
11
  # <!-- start text/html -->
12
12
  # <!-- end text/html -->
13
13
  #
14
14
  # TODO: add support for DL, OL
15
+ # TODO: this is not safe and needs a real html parser to work
15
16
  def convert_to_text(html, line_length = 65, from_charset = 'UTF-8')
16
17
  txt = html
17
18
 
@@ -26,17 +27,17 @@ module HtmlToPlainText
26
27
  # eg. the following formats:
27
28
  # <img alt="" />
28
29
  # <img alt="">
29
- txt.gsub!(/<img.+?alt=\"([^\"]*)\"[^>]*\>/i, '\1')
30
+ txt.gsub!(/<img[^>]+?alt="([^"]*)"[^>]*>/i, '\1')
30
31
 
31
32
  # for img tags with '' for attribute quotes
32
33
  # with or without closing tag
33
34
  # eg. the following formats:
34
35
  # <img alt='' />
35
36
  # <img alt=''>
36
- txt.gsub!(/<img.+?alt=\'([^\']*)\'[^>]*\>/i, '\1')
37
+ txt.gsub!(/<img[^>]+?alt='([^']*)'[^>]*>/i, '\1')
37
38
 
38
39
  # remove script tags and content
39
- txt.gsub!(/<script.*\/script>/m, '')
40
+ txt.gsub!(/<script.*?\/script>/m, '')
40
41
 
41
42
  # links with double quotes
42
43
  txt.gsub!(/<a\s[^\n]*?href=["'](mailto:)?([^"]*)["][^>]*>(.*?)<\/a>/im) do |s|
@@ -75,12 +76,12 @@ module HtmlToPlainText
75
76
  hlength = line_length if hlength > line_length
76
77
 
77
78
  case hlevel
78
- when 1 # H1, asterisks above and below
79
- htext = ('*' * hlength) + "\n" + htext + "\n" + ('*' * hlength)
80
- when 2 # H1, dashes above and below
81
- htext = ('-' * hlength) + "\n" + htext + "\n" + ('-' * hlength)
82
- else # H3-H6, dashes below
83
- htext = htext + "\n" + ('-' * hlength)
79
+ when 1 # H1, asterisks above and below
80
+ htext = ('*' * hlength) + "\n" + htext + "\n" + ('*' * hlength)
81
+ when 2 # H1, dashes above and below
82
+ htext = ('-' * hlength) + "\n" + htext + "\n" + ('-' * hlength)
83
+ else # H3-H6, dashes below
84
+ htext = htext + "\n" + ('-' * hlength)
84
85
  end
85
86
 
86
87
  "\n\n" + htext + "\n\n"
@@ -1,4 +1,4 @@
1
1
  class Premailer
2
2
  # Premailer version.
3
- VERSION = '1.12.0'.freeze
3
+ VERSION = '1.12.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.12.0
4
+ version: 1.12.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-07-11 00:00:00.000000000 Z
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser