gitlabhq/lib/redcarpet/render/gitlab_html.rb

26 lines
590 B
Ruby
Raw Normal View History

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)
2012-11-10 00:55:56 +01:00
options = { options: {encoding: 'utf-8'} }
if Pygments::Lexer.find(language)
2012-11-10 00:55:56 +01:00
Pygments.highlight(code, options.merge(lexer: language.downcase))
else
2012-11-10 00:55:56 +01:00
Pygments.highlight(code, options)
end
end
def postprocess(full_document)
h.gfm(full_document)
end
end