Commit e1b4e22e authored by Riyad Preukschas's avatar Riyad Preukschas

Add render context to markdown renderer

parent 058b71ed
......@@ -43,7 +43,7 @@ module ApplicationHelper
end
def markdown(text)
@__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(filter_html: true), {
@__renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::GitlabHTML.new(self, filter_html: true), {
no_intra_emphasis: true,
tables: true,
fenced_code_blocks: true,
......
class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
attr_reader :template
alias_method :h, :template
def initialize(template, options = {})
@template = template
@project = @template.instance_variable_get("@project")
super options
end
def block_code(code, language)
if Pygments::Lexer.find(language)
Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment