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