Commit e1b4e22e authored by Riyad Preukschas's avatar Riyad Preukschas

Add render context to markdown renderer

parent 058b71ed
...@@ -43,7 +43,7 @@ module ApplicationHelper ...@@ -43,7 +43,7 @@ module ApplicationHelper
end end
def markdown(text) 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, no_intra_emphasis: true,
tables: true, tables: true,
fenced_code_blocks: true, fenced_code_blocks: true,
......
class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML 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) def block_code(code, language)
if Pygments::Lexer.find(language) if Pygments::Lexer.find(language)
Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'}) 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