html2text 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzZiNWFhNDM0MzgxN2FmOWU4MDk2MDAyZWUyNDZmZGM3NGYyNTBmYw==
4
+ Mjk5MjBiMzliYjc0Y2IyNDRkOThkNTJhNTBjNGFlZTMzNjM5NTU0YQ==
5
5
  data.tar.gz: !binary |-
6
- NTg0NzNhNDk3ZmQyYzZiZmFmYWJkYzk3MWI4Y2VhMzU4ZmUzMDhhOQ==
6
+ NjlhZDRjZjg4MjhjMjcxNGJkNzcyMDg5Mzk0Y2Q0MjA4MTM2MDJmMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTViOTczNzNjZTk5MTNlNDczMGYzY2IzNTg5NmIxZTg2YmQ2MzkxMWM4YjQ2
10
- ZDQxN2I0MTc1ZjliYWJkODgyMDQ4NzU5OTY2NTVmZWJkNWMyMTIzYWEzMmE0
11
- MGQyYjFiMGRlYTFiNGU4ZDg1N2QwZTRiZGE0NTM4NTE0ODY5YjU=
9
+ MDAxNDJiYzY3Mjg1NjhiMWMzOGFmM2U5ZjJkNzQ0MGYwMTFiYjM5Njg0N2M0
10
+ OGU4NGM3ZjYwZGJjYzdmZWFlZWUyMzBkNTI1MzIxZDFhMjIwM2E1ZmI2NDI0
11
+ ZDk3ODViYmRkZGQ4MWUwNmRkMzFmOTE2NjQ3ZWRkZmQ0M2NlYzI=
12
12
  data.tar.gz: !binary |-
13
- YWE0NWI1MDBmOGUyZTYwOWYzNjJhYThhNWQ1Yzk5NTc5ZmFlYWVhNWE2MzI3
14
- Mjg3YTM3OGUyYTlkMWQzMWJiMzhlZTJkMzg1MTFiZTIyZWFiZDAxMmEwZmJj
15
- ZjViZGIzZjNhYzAyYmMxY2ZjNjRkOGRhZWNhMTJmYTkzZTQ5OGU=
13
+ OWQ3MzM4ZTkyODA2ZmE0YThjZTA5MjhjYTQ1YzNiYjhjMzJmNWUyMDViNDE5
14
+ NGMxNGJjZDAwYzZjODJlYWRhOTc5NjY0YmFhNTZlOGFlMzNiNzE1ODE5Njgw
15
+ MmY0ODNmZDMzZTdkNjNjNTBmNTRmNzBjNTY3NDNhMjg0YjlmZWQ=
File without changes
@@ -19,17 +19,22 @@ class Html2Text
19
19
  end
20
20
 
21
21
  def self.replace_entities(text)
22
- text.gsub(" ", " ")
22
+ text.gsub(" ", " ").gsub("\u00a0", " ")
23
23
  end
24
24
 
25
25
  def convert
26
26
  output = iterate_over(doc)
27
27
  output = remove_leading_and_trailing_whitespace(output)
28
+ output = remove_unnecessary_empty_lines(output)
28
29
  output.strip
29
30
  end
30
31
 
31
32
  def remove_leading_and_trailing_whitespace(text)
32
- text.gsub(/[ \t]*\n[ \t]*/im, "\n")
33
+ text.gsub(/[ \t]*\n[ \t]*/im, "\n").gsub(/ *\t */im, "\t")
34
+ end
35
+
36
+ def remove_unnecessary_empty_lines(text)
37
+ text.gsub(/\n\n\n*/im, "\n\n")
33
38
  end
34
39
 
35
40
  def trimmed_whitespace(text)
@@ -69,6 +74,9 @@ class Html2Text
69
74
  if node.name.downcase == "a"
70
75
  output = wrap_link(node, output)
71
76
  end
77
+ if node.name.downcase == "img"
78
+ output = image_text(node)
79
+ end
72
80
 
73
81
  output
74
82
  end
@@ -76,7 +84,7 @@ class Html2Text
76
84
  def prefix_whitespace(node)
77
85
  case node.name.downcase
78
86
  when "hr"
79
- "------\n"
87
+ "---------------------------------------------------------------\n"
80
88
 
81
89
  when "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul"
82
90
  "\n"
@@ -115,6 +123,23 @@ class Html2Text
115
123
  href = node.attribute("href")
116
124
  name = node.attribute("name")
117
125
 
126
+ output = output.strip
127
+
128
+ # remove double [[ ]]s from linking images
129
+ if output[0] == "[" && output[-1] == "]"
130
+ output = output[1, output.length - 2]
131
+
132
+ # for linking images, the title of the <a> overrides the title of the <img>
133
+ if node.attribute("title")
134
+ output = node.attribute("title").to_s
135
+ end
136
+ end
137
+
138
+ # if there is no link text, but a title attr
139
+ if output.empty? && node.attribute("title")
140
+ output = node.attribute("title").to_s
141
+ end
142
+
118
143
  if href.nil?
119
144
  if !name.nil?
120
145
  output = "[#{output}]"
@@ -124,7 +149,11 @@ class Html2Text
124
149
 
125
150
  if href != output && href != "mailto:#{output}" &&
126
151
  href != "http://#{output}" && href != "https://#{output}"
127
- output = "[#{output}](#{href})"
152
+ if output.empty?
153
+ output = href
154
+ else
155
+ output = "[#{output}](#{href})"
156
+ end
128
157
  end
129
158
  end
130
159
 
@@ -135,4 +164,14 @@ class Html2Text
135
164
 
136
165
  output
137
166
  end
167
+
168
+ def image_text(node)
169
+ if node.attribute("title")
170
+ "[" + node.attribute("title").to_s + "]"
171
+ elsif node.attribute("alt")
172
+ "[" + node.attribute("alt").to_s + "]"
173
+ else
174
+ ""
175
+ end
176
+ end
138
177
  end
@@ -1,3 +1,3 @@
1
1
  class Html2Text
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,5 +1,5 @@
1
- A document without any HTML open/closing tags.
2
- ------
3
- We try and use the representation given by common browsers of the HTML document, so that it looks similar when converted to plain text. [visit foo.com](http://foo.com) - or http://www.foo.com [link](http://foo.com)
4
-
1
+ A document without any HTML open/closing tags.
2
+ ---------------------------------------------------------------
3
+ We try and use the representation given by common browsers of the HTML document, so that it looks similar when converted to plain text. [visit foo.com](http://foo.com) - or http://www.foo.com [link](http://foo.com)
4
+
5
5
  [An anchor which will not appear]
@@ -0,0 +1,220 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <meta name="viewport" content="width=680">
6
+ </head>
7
+ <body class="cat-update-email cat-update" style="background: #ffccee; color: blue; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; text-align: center" bgcolor="#ffccee">
8
+ <style type="text/css">
9
+ body.cat-update-email {
10
+ margin: 0; padding: 0; background: #ffccee; color: blue; text-align: center;
11
+ }
12
+ body.cat-update-email {
13
+ font-size: 12px; font-family: Times New Roman; font-weight: normal;
14
+ }
15
+ body.cat-update-email th {
16
+ font-size: 12px; font-family: Times New Roman; font-weight: normal;
17
+ }
18
+ body.cat-update-email td {
19
+ font-size: 12px; font-family: Times New Roman; font-weight: normal;
20
+ }
21
+ </style>
22
+ <table class="header-wrapper" style="border-spacing: 0; border: none; margin: 0; width: 100%">
23
+ <tr>
24
+ <td class="header" style="background: none; color: #999; font-family: Times New Roman; font-size: 12px; font-weight: normal; padding: 15px 0">
25
+ <table cellspacing="0" cellpadding="0" border="0" style="margin: 0 auto; padding: 0 20px; width: 640px">
26
+ <tr>
27
+ <th style="font-family: Times New Roman; font-size: 12px; font-weight: normal">
28
+ <a class="logo" href="http://localhost/home" style="color: red; text-decoration: none">
29
+ <img border="0" height="32" src="test.png" width="200" style="display: block">
30
+ </a> </th>
31
+ <td class="account-number" style="color: white; font-family: Times New Roman; font-size: 12px; font-weight: normal; text-align: right" align="right">
32
+ 16 December 2015<br>
33
+ Account 123
34
+ </td>
35
+ </tr>
36
+ </table>
37
+ </td>
38
+ </tr>
39
+ </table>
40
+
41
+ <table class="section-wrapper" style="border-spacing: 0; border: none; margin: 0 auto 20px; width: 640px">
42
+ <tr>
43
+ <td class="salutation section" style="background: white; color: black; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0 auto 20px; padding: 40px 20px; text-align: left; width: 600px" align="left" bgcolor="white">
44
+ <h1 class="user_greeting" style="font-family: Times New Roman; font-size: 1.8; font-weight: normal; line-height: 1.2; margin: 0 0 1em">
45
+ Hi Susan
46
+ </h1>
47
+ <p class="message" style="font-size: 1.5em; line-height: 1.2; margin: 0">
48
+ Here is your cat report.
49
+ </p>
50
+
51
+ </td>
52
+ </tr>
53
+ </table>
54
+
55
+
56
+
57
+
58
+ <table class="section-wrapper" style="border-spacing: 0; border: none; margin: 0 auto 20px; width: 640px">
59
+ <tr>
60
+ <td class="balance section" style="background: white; color: black; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0 auto 20px; padding: 40px 20px; text-align: left; width: 600px" align="left" bgcolor="white">
61
+ <div class="account-status-heading" style="font-size: 2.5em; line-height: 1em; padding: 30px 20px; text-align: center" align="center">You have found <span class="status-cats-negative" style="color: #df0000">5 cats</span> less than anyone else</div>
62
+
63
+ <div id="cat-update-action-buttons">
64
+ <div id="buy-button" style="text-align: center" align="center">
65
+ <a class="btn-alert" href="http://localhost/cats" id="buy-cats-button" style="-moz-appearance: none; -webkit-appearance: none; background: #DF0000; border-radius: 3px; border: 11px solid #df0000; color: #fff; cursor: pointer; display: block; font-size: 16px; height: 16px; line-height: 16px; margin: 0 auto; text-decoration: none; transition: background-color .15s; width: 120px">Find more cats</a>
66
+ </div>
67
+ </div>
68
+ </td>
69
+ </tr>
70
+ </table>
71
+
72
+ <table class="section-wrapper" style="border-spacing: 0; border: none; margin: 0 auto 20px; width: 640px">
73
+ <tr>
74
+ <td class="cats section" id="cats" style="background: white; color: black; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0 auto 20px; padding: 40px 20px; text-align: left; width: 600px" align="left" bgcolor="white">
75
+ <div class="cats-usage">
76
+ <h2 style="font-family: Times New Roman; font-size: 1.8; font-weight: normal; line-height: 1.2; margin: 0">Down the road</h2>
77
+ <p class="fine-print" style="margin: 0">Across the hall</p>
78
+
79
+ <h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 10px 0 0">Your achievements</h3>
80
+ <table class="current-usage with-icon-left" style="border-collapse: collapse; border-spacing: 0; margin-bottom: 20px; margin-top: 20px; width: 100%">
81
+ <tr>
82
+ <th style="border: none; font-family: Times New Roman; font-size: 14px; font-weight: bold; margin: 0; padding: 0; text-align: left; vertical-align: middle; width: 50px" align="left" valign="middle"><img src="test.png"></th>
83
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; vertical-align: top; width: 550px" valign="top">
84
+ <div class="top">You're currently finding about</div>
85
+ <div class="large" style="color: black; font-size: 18px; padding: 4px 0">12 cats</div>
86
+ <div class="bottom">per day</div>
87
+ </td>
88
+ </tr>
89
+ <tr><td colspan="2" style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; vertical-align: top; width: 550px" valign="top"> </td></tr>
90
+ <tr>
91
+ <td colspan="2" style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; vertical-align: top; width: 550px" valign="top"><img alt="Number of cats found" src="test.png"></td>
92
+ </tr>
93
+ </table>
94
+ </div>
95
+
96
+
97
+ <div class="summary">
98
+ <hr class="fine-print" style="border-bottom-color: #eee; border-bottom-style: solid; border-width: 0 0 1px; margin: 20px 0">
99
+
100
+ <h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 10px 0 0">Your last cat was found two days ago.</h3>
101
+ <p class="fine-print" style="margin: 0">One type of cat is a kitten.</p>
102
+
103
+ <table class="readings" style="border-collapse: collapse; border-spacing: 0; margin: 10px 0; width: 100%">
104
+ <tr style="color: #BD236C">
105
+ <td class="left-column" style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; width: 5%">
106
+ <img src="test.png" style="padding-top: 10px">
107
+ </td>
108
+ <td class="center-column" style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; width: 60%">
109
+ <h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 10px 0 0">Special account <span class="nickname" style="font-size: 12px"></span> <span class="fine-print">A1</span>
110
+ </h3>
111
+ </td>
112
+ <td class="right-column" style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0; width: 20%">
113
+ <h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 10px 0 0">12.345</h3>
114
+ </td>
115
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 0"></td>
116
+ </tr>
117
+ </table>
118
+
119
+ </div>
120
+
121
+ </td>
122
+ </tr>
123
+ </table>
124
+
125
+ <div class="banner" style="margin: 0 auto 20px; padding: 10px; text-align: center; width: 640px" align="center">
126
+ <a href="http://localhost/logout" style="color: red; text-decoration: none">
127
+ <img alt="" border="0" height="177" src="http://localhost/photo1.png" width="600">
128
+ </a>
129
+ </div>
130
+
131
+ <table class="section-wrapper" style="border-spacing: 0; border: none; margin: 0 auto 20px; width: 640px">
132
+ <tr>
133
+ <td class="tips section" style="background: white; color: black; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0 auto 20px; padding: 40px 20px; text-align: left; width: 600px" align="left" bgcolor="white">
134
+ <table style="border-collapse: collapse; border-spacing: 0; width: 100%">
135
+ <tr>
136
+ <td colspan="3" style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0; vertical-align: top; width: 200px" valign="top"><h2 style="font-family: Times New Roman; font-size: 1.8; font-weight: normal; line-height: 1.2; margin: 0 0 10px">How can you find more cats?</h2></td>
137
+ </tr>
138
+
139
+ <tr class="icon">
140
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0; vertical-align: top; width: 200px" valign="top"><img height="40" src="http://localhost/photo1.png" width="40"></td>
141
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top"><img height="40" src="http://localhost/photo2.png" width="40"></td>
142
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top"><img height="40" src="http://localhost/photo3.png" width="40"></td>
143
+ </tr>
144
+
145
+ <tr class="subtitle">
146
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0; vertical-align: top; width: 200px" valign="top"><h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 0 0 5px">Look in trash cans</h3></td>
147
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top"><h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 0 0 5px">Start meowing</h3></td>
148
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top"><h3 style="font-family: Times New Roman; font-size: 18px; font-weight: normal; line-height: 2em; margin: 0 0 5px">Eat cat food</h3></td>
149
+ </tr>
150
+
151
+ <tr class="body" style="color: green">
152
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0; vertical-align: top; width: 200px" valign="top">Some cats like to hang out in trash cans. Some cats do not.</td>
153
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top">Some cats are attracted to similar tones.</td>
154
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top">So one day your tears may smell like cat food, attracting more cats.</td>
155
+ </tr>
156
+
157
+ <tr class="image">
158
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0; vertical-align: top; width: 200px" valign="top">
159
+ <a href="https://localhost/about" style="color: red; text-decoration: none">
160
+ <img border="0" height="130" src="http://localhost/photo1.png" style="display: block; margin: 10px 0" width="165">
161
+ </a>
162
+ </td>
163
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top">
164
+ <a href="https://localhost/about" style="color: red; text-decoration: none">
165
+ <img border="0" height="130" src="http://localhost/photo2.png" style="display: block; margin: 10px 0" width="165">
166
+ </a>
167
+ </td>
168
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top">
169
+ <a href="https://localhost/about" style="color: red; text-decoration: none">
170
+ <img border="0" height="130" src="http://localhost/photo3.png" style="display: block; margin: 10px 0" width="165">
171
+ </a>
172
+ </td>
173
+ </tr>
174
+
175
+ <tr class="tips-footer" style="color: green">
176
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0; vertical-align: top; width: 200px" valign="top">
177
+ <a href="https://github.com/soundasleep/html2text_ruby" style="color: red; text-decoration: none">Cats are great.</a>
178
+ </td>
179
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top">
180
+ <a href="https://github.com/soundasleep/html2text_ruby" style="color: red; text-decoration: none">Find more cats.</a>
181
+ </td>
182
+ <td style="border: none; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0; padding: 5px 0 0 17px; vertical-align: top; width: 200px" valign="top">
183
+ <a href="https://github.com/soundasleep/html2text_ruby" style="color: red; text-decoration: none">Do more things.</a>
184
+ </td>
185
+ </tr>
186
+ </table>
187
+ </td>
188
+ </tr>
189
+ </table>
190
+
191
+
192
+
193
+
194
+
195
+ <table class="footer-wrapper" style="margin: 0 auto 20px">
196
+ <tr>
197
+ <td class="footer" style="color: #9B9B9B; font-family: Times New Roman; font-size: 12px; font-weight: normal; margin: 0 auto 4em; text-align: left; width: 600px" align="left">
198
+ <h3 style="font-family: Times New Roman; font-size: 1.2; font-weight: normal; line-height: 2em; margin: 0">
199
+ <a href="http://localhost/contact" style="color: red; text-decoration: none">Contact us</a>
200
+ </h3>
201
+ <p style="margin: 0 0 1em">
202
+ cats@cats.com<br>
203
+ Monday and Friday
204
+ </p>
205
+
206
+ <p style="margin: 0 0 1em"><a href="https://github.com/soundasleep/html2text" style="color: red; text-decoration: none"><img align="absmiddle" height="26" src="test.png" width="26"></a>
207
+ <a href="https://github.com/soundasleep/html2text_ruby" style="color: red; text-decoration: none"><img align="absmiddle" height="26" src="test.png" width="26"></a>
208
+ </p>
209
+
210
+ <p class="message no-web-display" style="margin: 0">Having trouble seeing this email?
211
+ <a href="http://localhost/view_it_online" style="color: red; text-decoration: none">View it online</a>.
212
+ </p>
213
+
214
+ </td>
215
+ </tr>
216
+ </table>
217
+ <script async type="text/javascript" id="profiler" src="/profiler.js" data-version="1.0"></script>
218
+ </body>
219
+ </html>
220
+
@@ -0,0 +1,54 @@
1
+ http://localhost/home 16 December 2015
2
+ Account 123
3
+
4
+ Hi Susan
5
+
6
+ Here is your cat report.
7
+
8
+ You have found 5 cats less than anyone else
9
+
10
+ [Find more cats](http://localhost/cats)
11
+
12
+ Down the road
13
+
14
+ Across the hall
15
+
16
+ Your achievements
17
+
18
+ You're currently finding about
19
+ 12 cats
20
+ per day
21
+
22
+ [Number of cats found]
23
+ ---------------------------------------------------------------
24
+
25
+ Your last cat was found two days ago.
26
+
27
+ One type of cat is a kitten.
28
+
29
+ Special account A1
30
+
31
+ 12.345
32
+
33
+ http://localhost/logout
34
+
35
+ How can you find more cats?
36
+
37
+ Look in trash cans
38
+
39
+ Start meowing
40
+
41
+ Eat cat food
42
+
43
+ Some cats like to hang out in trash cans. Some cats do not. Some cats are attracted to similar tones. So one day your tears may smell like cat food, attracting more cats.
44
+ https://localhost/about https://localhost/about https://localhost/about
45
+ [Cats are great.](https://github.com/soundasleep/html2text_ruby) [Find more cats.](https://github.com/soundasleep/html2text_ruby) [Do more things.](https://github.com/soundasleep/html2text_ruby)
46
+
47
+ [Contact us](http://localhost/contact)
48
+
49
+ cats@cats.com
50
+ Monday and Friday
51
+
52
+ https://github.com/soundasleep/html2text https://github.com/soundasleep/html2text_ruby
53
+
54
+ Having trouble seeing this email? [View it online](http://localhost/view_it_online).
@@ -0,0 +1,54 @@
1
+ <body>
2
+ <p>
3
+ One: <img src="one.png">
4
+ </p>
5
+
6
+ <p>
7
+ Two: <img src="two.png" alt="two">
8
+ </p>
9
+
10
+ <p>
11
+ Three: <img src="three.png" title="three">
12
+ </p>
13
+
14
+ <p>
15
+ Four: <img src="four.png" title="four" alt="four alt">
16
+ </p>
17
+
18
+ <h1>With links</h1>
19
+
20
+ <p>
21
+ One: <a href="http://localhost"><img src="one.png"></a>
22
+ </p>
23
+
24
+ <p>
25
+ Two: <a href="http://localhost"><img src="two.png" alt="two"></a>
26
+ </p>
27
+
28
+ <p>
29
+ Three: <a href="http://localhost"><img src="three.png" title="three"></a>
30
+ </p>
31
+
32
+ <p>
33
+ Four: <a href="http://localhost"><img src="four.png" title="four" alt="four alt"></a>
34
+ </p>
35
+
36
+ <h1>With links with titles</h1>
37
+
38
+ <p>
39
+ One: <a href="http://localhost" title="one link"><img src="one.png"></a>
40
+ </p>
41
+
42
+ <p>
43
+ Two: <a href="http://localhost" title="two link"><img src="two.png" alt="two"></a>
44
+ </p>
45
+
46
+ <p>
47
+ Three: <a href="http://localhost" title="three link"><img src="three.png" title="three"></a>
48
+ </p>
49
+
50
+ <p>
51
+ Four: <a href="http://localhost" title="four link"><img src="four.png" title="four" alt="four alt"></a>
52
+ </p>
53
+ </body>
54
+ </html>
@@ -0,0 +1,27 @@
1
+ One:
2
+
3
+ Two: [two]
4
+
5
+ Three: [three]
6
+
7
+ Four: [four]
8
+
9
+ With links
10
+
11
+ One: http://localhost
12
+
13
+ Two: [two](http://localhost)
14
+
15
+ Three: [three](http://localhost)
16
+
17
+ Four: [four](http://localhost)
18
+
19
+ With links with titles
20
+
21
+ One: [one link](http://localhost)
22
+
23
+ Two: [two link](http://localhost)
24
+
25
+ Three: [three link](http://localhost)
26
+
27
+ Four: [four link](http://localhost)
@@ -1,7 +1,7 @@
1
1
  Hello, World!
2
2
 
3
- Col A Col B
4
- Data A1 Data B1
5
- Data A2 Data B2
6
- Data A3 Data B4
7
- Total A Total B
3
+ Col A Col B
4
+ Data A1 Data B1
5
+ Data A2 Data B2
6
+ Data A3 Data B4
7
+ Total A Total B
@@ -12,6 +12,10 @@ describe Html2Text do
12
12
  let(:text_file) { filename.sub(".html", ".txt") }
13
13
  let(:expected) { Html2Text.fix_newlines(File.read(text_file)) }
14
14
 
15
+ it "has an expected output" do
16
+ expect(File.exist?(text_file)).to eq(true), "'#{text_file}' did not exist"
17
+ end
18
+
15
19
  it "converts to text" do
16
20
  expect(text).to eq(expected)
17
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jevon Wright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-17 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -87,7 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - MIT-LICENSE
90
+ - LICENSE.md
91
91
  - README.md
92
92
  - lib/html2text.rb
93
93
  - lib/html2text/version.rb
@@ -95,6 +95,10 @@ files:
95
95
  - spec/examples/anchors.txt
96
96
  - spec/examples/basic.html
97
97
  - spec/examples/basic.txt
98
+ - spec/examples/full_email.html
99
+ - spec/examples/full_email.txt
100
+ - spec/examples/images.html
101
+ - spec/examples/images.txt
98
102
  - spec/examples/lists.html
99
103
  - spec/examples/lists.txt
100
104
  - spec/examples/more-anchors.html
@@ -139,6 +143,10 @@ test_files:
139
143
  - spec/examples/anchors.txt
140
144
  - spec/examples/basic.html
141
145
  - spec/examples/basic.txt
146
+ - spec/examples/full_email.html
147
+ - spec/examples/full_email.txt
148
+ - spec/examples/images.html
149
+ - spec/examples/images.txt
142
150
  - spec/examples/lists.html
143
151
  - spec/examples/lists.txt
144
152
  - spec/examples/more-anchors.html