mirror of
https://github.com/discourse/discourse.git
synced 2025-08-21 19:11:18 +08:00
FIX: HtmlToMarkdown should not convert empty/bad <a> tags
This commit is contained in:
parent
1706036f2b
commit
edbf12622b
2 changed files with 14 additions and 3 deletions
|
@ -143,9 +143,14 @@ class HtmlToMarkdown
|
|||
end
|
||||
|
||||
def visit_a(node)
|
||||
@stack[-1].markdown << "["
|
||||
traverse(node)
|
||||
@stack[-1].markdown << "](#{node["href"]})"
|
||||
href = node["href"]
|
||||
if href.present? && (href.start_with?("http") || href.start_with?("www."))
|
||||
@stack[-1].markdown << "["
|
||||
traverse(node)
|
||||
@stack[-1].markdown << "](#{href})"
|
||||
else
|
||||
traverse(node)
|
||||
end
|
||||
end
|
||||
|
||||
def visit_tt(node)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue