Sha256: fd85eafa898e6c5dae11342b261a736d2e498d032c9ba0340495a8381259d71b
Contents?: true
Size: 722 Bytes
Versions: 22
Compression:
Stored size: 722 Bytes
Contents
module Troy class Markdown # Create a new Redcarpet renderer, that prepares the code block # to use Prisme.js syntax. # class Renderer < Redcarpet::Render::HTML def block_code(code, language) %[<pre class="language-#{language}"><code>#{CGI.escapeHTML(code)}</code></pre>] end end # Set the Markdown markup that must be rendered. # attr_reader :markup def initialize(markup) @markup = markup end def renderer @renderer ||= Redcarpet::Markdown.new(Renderer, { :autolink => true, :space_after_headers => true, :fenced_code_blocks => true }) end def to_html renderer.render(markup) end end end
Version data entries
22 entries across 22 versions & 1 rubygems