Add render context to markdown renderer
This commit is contained in:
parent
058b71edf3
commit
e1b4e22e5c
|
@ -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,
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
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…
Reference in a new issue