class Malt::Engine::RDiscount

Discount Markdown implementation.

@see github.com/rtomayko/rdiscount

The :smart and :filter_html options can be set true to enable those flags on the underlying RDiscount object.

Public Instance Methods

create_engine(params={}) click to toggle source

Convert Markdown text to create_engine engine object.

# File lib/malt/engines/rdiscount.rb, line 30
def create_engine(params={})
  text = parameters(params, :text)

  flags = engine_options(params)

  cached(text, flags) do
    ::RDiscount.new(text, *flags)
  end
end
render(params={}) click to toggle source

Convert Markdown text to HTML text.

Calls superclass method Malt::Engine::Abstract#render
# File lib/malt/engines/rdiscount.rb, line 18
def render(params={})
  into = parameters(params, :to)

  case into
  when :html, nil
    prepare_engine(params).to_html
  else
    super(params)
  end
end

Private Instance Methods

engine_options(params={}) click to toggle source
# File lib/malt/engines/rdiscount.rb, line 49
def engine_options(params={})
  [:smart, :filter_html].select{ |flag| params[flag] || settings[flag] }
end
require_engine() click to toggle source

Load rdoc makup library if not already loaded.

# File lib/malt/engines/rdiscount.rb, line 43
def require_engine
  return if defined? ::RDiscount
  require_library 'rdiscount'
end