Skip to content
Snippets Groups Projects
Commit e1b4e22e authored by Riyad Preukschas's avatar Riyad Preukschas
Browse files

Add render context to markdown renderer

parent 058b71ed
No related branches found
No related tags found
1 merge request!1183Gitlab flavored markdown
Loading
Loading
@@ -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,
Loading
Loading
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'})
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment