rosa-build/lib/redcarpet/render/gitlab_html.rb

38 lines
916 B
Ruby
Raw Normal View History

2013-03-28 18:22:24 +00:00
# This class is based on
# https://github.com/gitlabhq/gitlabhq/blob/2bc78739a7aa9d7e5109281fc45dbd41a1a576d4/lib/gitlab/markdown.rb
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)
# New lines are placed to fix an rendering issue
# with code wrapped inside <h1> tag for next case:
#
# # Title kinda h1
#
# ruby code here
#
code_class = "class=\"#{language.downcase}\"" if language.present?
2013-03-28 18:22:24 +00:00
<<-HTML
2013-04-09 15:09:55 +01:00
<pre><code #{code_class}>#{code}</code></pre>
2013-03-28 18:22:24 +00:00
HTML
end
def link(link, title, content)
h.link_to_gfm(content, link, title: title)
end
def postprocess(full_document)
h.gfm(full_document)
end
end