mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:40:00 +08:00
FIX: properly support HTML document when converting to markdown
This commit is contained in:
parent
f05f1a24d3
commit
51ee49aad2
|
@ -7,7 +7,7 @@ class HtmlToMarkdown
|
|||
end
|
||||
|
||||
def initialize(html)
|
||||
@doc = Nokogiri::HTML.fragment(html)
|
||||
@doc = Nokogiri::HTML(html)
|
||||
remove_whitespaces!
|
||||
end
|
||||
|
||||
|
|
|
@ -142,6 +142,10 @@ describe HtmlToMarkdown do
|
|||
expect(html_to_markdown("<ul><li><p>A list item with a blockquote:</p><blockquote><p>This is a <strong>blockquote</strong><br>inside a list item.</p></blockquote></li></ul>")).to eq("- A list item with a blockquote:\n\n > This is a **blockquote**\n > inside a list item.")
|
||||
end
|
||||
|
||||
it "supports html document" do
|
||||
expect(html_to_markdown("<html><body>Hello<div>World</div></body></html>")).to eq("Hello\nWorld")
|
||||
end
|
||||
|
||||
it "handles <p>" do
|
||||
expect(html_to_markdown("<p>1st paragraph</p><p>2nd paragraph</p>")).to eq("1st paragraph\n\n2nd paragraph")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user