2012-04-17 17:02:21 -04:00
|
|
|
class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
|
2012-07-23 19:45:08 -04:00
|
|
|
|
|
|
|
attr_reader :template
|
|
|
|
alias_method :h, :template
|
|
|
|
|
|
|
|
def initialize(template, options = {})
|
|
|
|
@template = template
|
|
|
|
@project = @template.instance_variable_get("@project")
|
|
|
|
super options
|
|
|
|
end
|
|
|
|
|
2012-04-17 17:02:21 -04:00
|
|
|
def block_code(code, language)
|
2012-11-09 18:55:56 -05:00
|
|
|
options = { options: {encoding: 'utf-8'} }
|
|
|
|
|
2012-11-27 16:49:52 -05:00
|
|
|
h.content_tag :div, class: h.user_color_scheme_class do
|
|
|
|
if Pygments::Lexer.find(language)
|
|
|
|
Pygments.highlight(code, options.merge(lexer: language.downcase))
|
|
|
|
else
|
|
|
|
Pygments.highlight(code, options)
|
|
|
|
end.html_safe
|
2012-04-17 17:02:21 -04:00
|
|
|
end
|
|
|
|
end
|
2012-08-01 20:29:15 -04:00
|
|
|
|
|
|
|
def postprocess(full_document)
|
|
|
|
h.gfm(full_document)
|
|
|
|
end
|
2012-06-08 04:23:31 -04:00
|
|
|
end
|