summaryrefslogtreecommitdiff
path: root/lib/redcarpet
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-04-27 18:54:13 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-04-30 16:35:25 -0400
commitaa2cc670fe2c9de772c82d90df4ee2d8a77c23fc (patch)
tree403c34f8589864232db009a4960c7041d3a456c4 /lib/redcarpet
parent2d9edcada5135d1f72a2c284e93d8e5b18e00008 (diff)
downloadgitlab-ce-aa2cc670fe2c9de772c82d90df4ee2d8a77c23fc.tar.gz
Add Gitlab::Markdown::AutolinkFilter
Diffstat (limited to 'lib/redcarpet')
-rw-r--r--lib/redcarpet/render/gitlab_html.rb18
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb
index dc5fbe3c8e1..321be9202cc 100644
--- a/lib/redcarpet/render/gitlab_html.rb
+++ b/lib/redcarpet/render/gitlab_html.rb
@@ -8,13 +8,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
@color_scheme = color_scheme
@project = @template.instance_variable_get("@project")
@options = options.dup
- super options
- end
- def preprocess(full_document)
- # Redcarpet doesn't allow SMB links when `safe_links_only` is enabled.
- # FTP links are allowed, so we trick Redcarpet.
- full_document.gsub("smb://", "ftp://smb:")
+ super(options)
end
# If project has issue number 39, apostrophe will be linked in
@@ -25,6 +20,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
# This only influences regular text, code blocks are untouched.
def normal_text(text)
return text unless text.present?
+
text.gsub("'", "&rsquo;")
end
@@ -37,7 +33,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
# so we assume you're not using leading spaces that aren't tabs,
# and just replace them here.
if lexer.tag == 'make'
- code.gsub! /^ /, "\t"
+ code.gsub!(/^ /, "\t")
end
formatter = Rugments::Formatters::HTML.new(
@@ -46,17 +42,13 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
formatter.format(lexer.lex(code))
end
- def link(link, title, content)
- h.link_to_gfm(content, link, title: title)
- end
-
def postprocess(full_document)
- full_document.gsub!("ftp://smb:", "smb://")
-
full_document.gsub!("&rsquo;", "'")
+
unless @template.instance_variable_get("@project_wiki") || @project.nil?
full_document = h.create_relative_links(full_document)
end
+
h.gfm_with_options(full_document, @options)
end
end