提交 817399e3 编写于 作者: M Marin Jankovski

Show links with correct ref.

上级 810d90dd
......@@ -59,10 +59,10 @@ module GitlabMarkdownHelper
end
end
def create_relative_links(text, project_path_with_namespace)
to_be_fixed = text.split("\n").map { |a| a.scan(/\]\(([^(]+)\)/) }.reject{|b| b.empty? }.flatten.reject{|c| c.include?("http" || "www")}
to_be_fixed.each do |string|
text.gsub!(string, "/#{project_path_with_namespace}/blob/master/#{string}")
def create_relative_links(text, project_path_with_namespace, ref)
links = text.split("\n").map { |a| a.scan(/\]\(([^(]+)\)/) }.reject{|b| b.empty? }.flatten.reject{|c| c.include?("http" || "www")}
links.each do |string|
text.gsub!(string, "/#{project_path_with_namespace}/blob/#{ref}/#{string}")
end
text
end
......
......@@ -6,6 +6,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def initialize(template, options = {})
@template = template
@project = @template.instance_variable_get("@project")
@ref = @template.instance_variable_get("@ref")
super options
end
......@@ -33,7 +34,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end
def preprocess(full_document)
h.create_relative_links(full_document, @project.path_with_namespace)
h.create_relative_links(full_document, @project.path_with_namespace, @ref)
end
def postprocess(full_document)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册