Fixed autolinking to work better in more cases #1013 [Jamis Buck]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1099 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 64271335
......@@ -157,7 +157,14 @@ def escape_regexp(text)
# Turns all urls into clickable links.
def auto_link_urls(text)
text.gsub(/([^=><!:'"\/]|^)((http[s]?:\/\/)|(www\.))(\S+\b\/?)([[:punct:]]*)(\s|$)/, '\1<a href="\3\4\5">\3\4\5</a>\6\7')
text.gsub(/(<\w+.*?>|[^=!:'"\/]|^)((?:http[s]?:\/\/)|(?:www\.))([^\s<]+\/?)([[:punct:]]|\s|<|$)/) do
all, a, b, c, d = $&, $1, $2, $3, $4
if a =~ /<a\s/i # don't replace URL's that are already linked
all
else
%(#{a}<a href="#{b=="www."?"http://www.":b}#{c}">#{b}#{c}</a>#{d})
end
end
end
# Turns all email addresses into clickable links.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册