Sha256: 699ea3ae69e8c3418bf56d041e137f2651237ab5ea853d213070cebdf2bfa132

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

require 'redcarpet'
require 'active_copy/renderer'

# Compiles a Markdown file using the +Redcarpet+ template engine. Used
# by +ActionView+ in +config/initializers/markdown.rb+ to initiate
# Markdown template compilation for files that are not already
# precompiled.
module ActiveCopy
  class Markdown
    # Create a new session with the compiler.
    def initialize
      @renderer = ActiveCopy::Renderer.new
      @options = {
        autolink: true,
        no_intra_emphasis: true,
        fenced_code_blocks: true,
        lax_html_blocks: true,
        strikethrough: true,
        superscript: true
      }
    end

    # Return an HTML String containing the rendered output of the Markdown
    # source.
    def render markdown_source
      markdown.render "#{markdown_source}"
    end

  private
    def markdown
      @client ||= Redcarpet::Markdown.new @renderer, @options
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_copy-1.0.0 lib/active_copy/markdown.rb
active_copy-1.0.0.pre lib/active_copy/markdown.rb