summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-21 10:31:15 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-21 10:31:15 +0200
commitc242ca9a177c0a101e2a02541830ffe56a1ae23e (patch)
treec99e765f47d2b00b00ec5a4b9323274de2ffe734 /lib
parent96c03199dddf36cbd0e2ad4089be535d73b26adc (diff)
downloadgitlab-ce-c242ca9a177c0a101e2a02541830ffe56a1ae23e.tar.gz
Get imported links to render correctly by not escaping all special chars.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/google_code_import/importer.rb22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index 5c7ac7fc4b7..3916e51d0ab 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -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