Sometimes spaces are removed which should be still there (e. g. in case of <div>some text <a>123</a>).
This commit is contained in:
parent
8f3fe2b399
commit
14c1407448
3 changed files with 27 additions and 14 deletions
|
@ -303,7 +303,7 @@ cleanup html string:
|
||||||
if node.previous.name == 'div' || node.previous.name == 'p'
|
if node.previous.name == 'div' || node.previous.name == 'p'
|
||||||
content.strip!
|
content.strip!
|
||||||
end
|
end
|
||||||
elsif node.parent && !node.previous
|
elsif node.parent && !node.previous && (!node.next || node.next.name == 'div' || node.next.name == 'p' || node.next.name == 'br')
|
||||||
if (node.parent.name == 'div' || node.parent.name == 'p') && content != ' ' && content != "\n"
|
if (node.parent.name == 'div' || node.parent.name == 'p') && content != ' ' && content != "\n"
|
||||||
content.strip!
|
content.strip!
|
||||||
end
|
end
|
||||||
|
|
|
@ -874,6 +874,19 @@ christian.schaefer@example.com'
|
||||||
#result = '<p>http://www.example.com/?wm=mail <a href="http://www.example.com/?wm=mail" rel="nofollow" target="_blank"><img border="0" src="cid:example_new.png@8B201D8C.000B" style="width:101px;height:30px;"></a></p>'
|
#result = '<p>http://www.example.com/?wm=mail <a href="http://www.example.com/?wm=mail" rel="nofollow" target="_blank"><img border="0" src="cid:example_new.png@8B201D8C.000B" style="width:101px;height:30px;"></a></p>'
|
||||||
result = '<p><a href="http://www.example.com/?wm=mail" rel="nofollow" target="_blank">http://www.example.com/?wm=mail</a></p>'
|
result = '<p><a href="http://www.example.com/?wm=mail" rel="nofollow" target="_blank">http://www.example.com/?wm=mail</a></p>'
|
||||||
assert_equal(result, html.html2html_strict)
|
assert_equal(result, html.html2html_strict)
|
||||||
|
|
||||||
|
html = '<div class="">Wir brauchen also die Instanz <a href="http://example.zammad.com" class="">example.zammad.com</a>, kann die aber nicht mehr nutzen.</div><div class=""><br class=""></div><div class="">Bitte um Freischaltung.</div><div class=""><br class=""></div><div class=""><br class=""><div class="">'
|
||||||
|
result = '<div>Wir brauchen also die Instanz <a href="http://example.zammad.com" rel="nofollow" target="_blank">example.zammad.com</a>, kann die aber nicht mehr nutzen.</div><div> </div><div>Bitte um Freischaltung.</div><div> </div><div>
|
||||||
|
<br><div></div>
|
||||||
|
</div>'
|
||||||
|
assert_equal(result, html.html2html_strict)
|
||||||
|
|
||||||
|
html = '<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">oh jeee … Zauberwort vergessen ;-) Können Sie mir
|
||||||
|
<b>bitte</b> noch meine Testphase verlängern?<o:p></o:p></span></p>
|
||||||
|
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>'
|
||||||
|
result = '<p>oh jeee … Zauberwort vergessen ;-) Können Sie mir <b>bitte</b> noch meine Testphase verlängern?</p><p> </p>'
|
||||||
|
assert_equal(result, html.html2html_strict)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'inline attachment replace' do
|
test 'inline attachment replace' do
|
||||||
|
|
|
@ -320,7 +320,7 @@ Registergericht / Commercial Register of the Local Court: HRB 0000 AG Hof',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: IO.binread('test/fixtures/mail10.box'),
|
data: IO.binread('test/fixtures/mail10.box'),
|
||||||
body_md5: '3774c850f4e4064b86f66163a3453e47',
|
body_md5: 'f0faf588a83fabf38a87b91614f55113',
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
md5: '52d946fdf1a9304d0799cceb2fcf0e36',
|
md5: '52d946fdf1a9304d0799cceb2fcf0e36',
|
||||||
|
@ -379,7 +379,7 @@ Newsletter abbestellen (<a href="http://newsletters.cylex.de/ref/www.cylex.de/si
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: IO.binread('test/fixtures/mail12.box'),
|
data: IO.binread('test/fixtures/mail12.box'),
|
||||||
body_md5: 'eacbca29d25cd10aa0f7e2ca558d38f2',
|
body_md5: '3e4b8cffd13a96fd88cbc45378d6eb00',
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
md5: '46cf0f95ea0c8211cbb704e1959b9173',
|
md5: '46cf0f95ea0c8211cbb704e1959b9173',
|
||||||
|
@ -552,7 +552,7 @@ Newsletter abbestellen (<a href="http://newsletters.cylex.de/ref/www.cylex.de/si
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: IO.binread('test/fixtures/mail19.box'),
|
data: IO.binread('test/fixtures/mail19.box'),
|
||||||
body_md5: '790a98dd429733c7fd8afc6fdd82e2a2',
|
body_md5: '4355c52fdfd2adea0cda6814adb78ae3',
|
||||||
params: {
|
params: {
|
||||||
from: '"我" <>',
|
from: '"我" <>',
|
||||||
from_email: '"我" <>',
|
from_email: '"我" <>',
|
||||||
|
@ -712,7 +712,7 @@ end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: IO.binread('test/fixtures/mail29.box'),
|
data: IO.binread('test/fixtures/mail29.box'),
|
||||||
body_md5: '2c0e700d4fdb1fe0e9a411234f39aa6f',
|
body_md5: '01036d03b8da2d32a603bc2124dfc671',
|
||||||
params: {
|
params: {
|
||||||
from: 'Example Sales <sales@example.com>',
|
from: 'Example Sales <sales@example.com>',
|
||||||
from_email: 'sales@example.com',
|
from_email: 'sales@example.com',
|
||||||
|
@ -773,7 +773,7 @@ end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: IO.binread('test/fixtures/mail36.box'),
|
data: IO.binread('test/fixtures/mail36.box'),
|
||||||
body_md5: '0c03749418faa758ee385a1fc9f01fbc',
|
body_md5: '8647b92d2495fe5f1c588163abc44b6b',
|
||||||
params: {
|
params: {
|
||||||
from: 'Martin Smith <m.Smith@example.com>',
|
from: 'Martin Smith <m.Smith@example.com>',
|
||||||
from_email: 'm.Smith@example.com',
|
from_email: 'm.Smith@example.com',
|
||||||
|
@ -931,7 +931,7 @@ end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: IO.binread('test/fixtures/mail43.box'),
|
data: IO.binread('test/fixtures/mail43.box'),
|
||||||
body_md5: '9de73d8cf7fdda5ca82bc3db8409ce5c',
|
body_md5: '11d3e78656f8f2105af431dd543c99f6',
|
||||||
params: {
|
params: {
|
||||||
from: 'Paula <databases.en@example.com>',
|
from: 'Paula <databases.en@example.com>',
|
||||||
from_email: 'databases.en@example.com',
|
from_email: 'databases.en@example.com',
|
||||||
|
|
Loading…
Reference in a new issue