mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00:00
FIX: handle multiple paragraphs in email reply when parsing html
This commit is contained in:
parent
c46b9c0ac3
commit
b457005b07
@ -76,7 +76,7 @@ module Email
|
|||||||
def add_newlines(doc)
|
def add_newlines(doc)
|
||||||
# Replace <br> tags with a markdown \n
|
# Replace <br> tags with a markdown \n
|
||||||
doc.xpath('//br').each do |br|
|
doc.xpath('//br').each do |br|
|
||||||
br.replace(new_linebreak_node doc)
|
br.replace(new_linebreak_node doc, 2)
|
||||||
end
|
end
|
||||||
# Surround <p> tags with newlines, to help with line-wise postprocessing
|
# Surround <p> tags with newlines, to help with line-wise postprocessing
|
||||||
# and ensure markdown paragraphs
|
# and ensure markdown paragraphs
|
||||||
|
@ -82,6 +82,17 @@ Thanks for listening."
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "handles multiple paragraphs when parsing html" do
|
||||||
|
test_parse_body(fixture_file("emails/html_paragraphs.eml")).
|
||||||
|
should == (
|
||||||
|
"Awesome!
|
||||||
|
|
||||||
|
Pleasure to have you here!
|
||||||
|
|
||||||
|
:boom:"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
it "converts back to UTF-8 at the end" do
|
it "converts back to UTF-8 at the end" do
|
||||||
result = test_parse_body(fixture_file("emails/big5.eml"))
|
result = test_parse_body(fixture_file("emails/big5.eml"))
|
||||||
result.encoding.should == Encoding::UTF_8
|
result.encoding.should == Encoding::UTF_8
|
||||||
|
BIN
spec/fixtures/emails/html_paragraphs.eml
vendored
Normal file
BIN
spec/fixtures/emails/html_paragraphs.eml
vendored
Normal file
Binary file not shown.
BIN
spec/fixtures/emails/paragraphs.eml
vendored
BIN
spec/fixtures/emails/paragraphs.eml
vendored
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user