Improved html2text.

This commit is contained in:
Martin Edenhofer 2016-01-13 11:03:34 +01:00
parent 6bb8c7b6eb
commit 7434971416
2 changed files with 41 additions and 34 deletions

View file

@ -103,6 +103,9 @@ class String
# remove style tags with content
string.gsub!( %r{<style(|\s.+?)>(.+?)</style>}im, '')
# insert spaces on [A-z]\n[A-z]
string.gsub!( /([A-z])\n([A-z])/m, '\1 \2' )
# remove empty lines
string.gsub!( /^\s*/m, '' )

View file

@ -105,6 +105,10 @@ class AaaStringTest < ActiveSupport::TestCase
result = "test col \ntest 4711"
assert_equal(result, html.html2text)
html = "<p><span>Was\nsoll verbessert werden:</span></p>"
result = 'Was soll verbessert werden:'
assert_equal(result, html.html2text)
html = "<!-- some comment -->
<div>
test<br><br><br>\n<br>\n<br>\n