Get imported links to render correctly by not escaping all special chars.

This commit is contained in:
Douwe Maan 2015-04-21 10:31:15 +02:00
parent 96c03199dd
commit c242ca9a17
1 changed files with 10 additions and 12 deletions

View File

@ -207,21 +207,19 @@ module Gitlab
end
def escape_for_markdown(s)
s = s.gsub("*", "\\*")
s = s.gsub("#", "\\#")
# No headings and lists
s = s.gsub(/^#/, "\\#")
s = s.gsub(/^-/, "\\-")
# No inline code
s = s.gsub("`", "\\`")
s = s.gsub(":", "\\:")
s = s.gsub("-", "\\-")
s = s.gsub("+", "\\+")
s = s.gsub("_", "\\_")
s = s.gsub("(", "\\(")
s = s.gsub(")", "\\)")
s = s.gsub("[", "\\[")
s = s.gsub("]", "\\]")
s = s.gsub("<", "\\<")
s = s.gsub(">", "\\>")
# Carriage returns make me sad
s = s.gsub("\r", "")
# Markdown ignores single newlines, but we need them as <br />.
s = s.gsub("\n", " \n")
s
end