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

Version Path
troy-0.0.22 lib/troy/markdown.rb
troy-0.0.21 lib/troy/markdown.rb
troy-0.0.20 lib/troy/markdown.rb
troy-0.0.19 lib/troy/markdown.rb
troy-0.0.18 lib/troy/markdown.rb
troy-0.0.17 lib/troy/markdown.rb
troy-0.0.16 lib/troy/markdown.rb
troy-0.0.15 lib/troy/markdown.rb
troy-0.0.14 lib/troy/markdown.rb
troy-0.0.13 lib/troy/markdown.rb
troy-0.0.12 lib/troy/markdown.rb
troy-0.0.11 lib/troy/markdown.rb
troy-0.0.10 lib/troy/markdown.rb
troy-0.0.9 lib/troy/markdown.rb
troy-0.0.8 lib/troy/markdown.rb
troy-0.0.7 lib/troy/markdown.rb
troy-0.0.6 lib/troy/markdown.rb
troy-0.0.5 lib/troy/markdown.rb
troy-0.0.4 lib/troy/markdown.rb
troy-0.0.3 lib/troy/markdown.rb