diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-21 10:31:15 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-21 10:31:15 +0200 |
commit | c242ca9a177c0a101e2a02541830ffe56a1ae23e (patch) | |
tree | c99e765f47d2b00b00ec5a4b9323274de2ffe734 /lib | |
parent | 96c03199dddf36cbd0e2ad4089be535d73b26adc (diff) | |
download | gitlab-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.rb | 22 |
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 |