Commit e1b4e22e5c59b9ef97892515755627857ae87185
1 parent
058b71ed
Exists in
master
and in
4 other branches
Add render context to markdown renderer
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -43,7 +43,7 @@ module ApplicationHelper |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | def markdown(text) |
| 46 | - @__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(filter_html: true), { | |
| 46 | + @__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(self, filter_html: true), { | |
| 47 | 47 | no_intra_emphasis: true, |
| 48 | 48 | tables: true, |
| 49 | 49 | fenced_code_blocks: true, | ... | ... |
lib/redcarpet/render/gitlab_html.rb
| 1 | 1 | class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML |
| 2 | + | |
| 3 | + attr_reader :template | |
| 4 | + alias_method :h, :template | |
| 5 | + | |
| 6 | + def initialize(template, options = {}) | |
| 7 | + @template = template | |
| 8 | + @project = @template.instance_variable_get("@project") | |
| 9 | + super options | |
| 10 | + end | |
| 11 | + | |
| 2 | 12 | def block_code(code, language) |
| 3 | 13 | if Pygments::Lexer.find(language) |
| 4 | 14 | Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'}) | ... | ... |