Commit 817399e3be6bda06ed7b4c61eb8192a532ed735e
1 parent
810d90dd
Exists in
master
and in
4 other branches
Show links with correct ref.
Showing
2 changed files
with
6 additions
and
5 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
| ... | ... | @@ -59,10 +59,10 @@ module GitlabMarkdownHelper |
| 59 | 59 | end |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | - def create_relative_links(text, project_path_with_namespace) | |
| 63 | - to_be_fixed = text.split("\n").map { |a| a.scan(/\]\(([^(]+)\)/) }.reject{|b| b.empty? }.flatten.reject{|c| c.include?("http" || "www")} | |
| 64 | - to_be_fixed.each do |string| | |
| 65 | - text.gsub!(string, "/#{project_path_with_namespace}/blob/master/#{string}") | |
| 62 | + def create_relative_links(text, project_path_with_namespace, ref) | |
| 63 | + links = text.split("\n").map { |a| a.scan(/\]\(([^(]+)\)/) }.reject{|b| b.empty? }.flatten.reject{|c| c.include?("http" || "www")} | |
| 64 | + links.each do |string| | |
| 65 | + text.gsub!(string, "/#{project_path_with_namespace}/blob/#{ref}/#{string}") | |
| 66 | 66 | end |
| 67 | 67 | text |
| 68 | 68 | end | ... | ... |
lib/redcarpet/render/gitlab_html.rb
| ... | ... | @@ -6,6 +6,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML |
| 6 | 6 | def initialize(template, options = {}) |
| 7 | 7 | @template = template |
| 8 | 8 | @project = @template.instance_variable_get("@project") |
| 9 | + @ref = @template.instance_variable_get("@ref") | |
| 9 | 10 | super options |
| 10 | 11 | end |
| 11 | 12 | |
| ... | ... | @@ -33,7 +34,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML |
| 33 | 34 | end |
| 34 | 35 | |
| 35 | 36 | def preprocess(full_document) |
| 36 | - h.create_relative_links(full_document, @project.path_with_namespace) | |
| 37 | + h.create_relative_links(full_document, @project.path_with_namespace, @ref) | |
| 37 | 38 | end |
| 38 | 39 | |
| 39 | 40 | def postprocess(full_document) | ... | ... |