Class: Malt::Engine::Maruku

Inherits:
Abstract show all
Defined in:
lib/malt/engines/maruku.rb

Overview

Redcarpet Markdown implementation.

http://maruku.rubyforge.org/

Instance Attribute Summary

Attributes inherited from Abstract

#settings

Instance Method Summary collapse

Methods inherited from Abstract

#cache?, default, #initialize, #prepare_engine, register, type

Constructor Details

This class inherits a constructor from Malt::Engine::Abstract

Instance Method Details

#create_engine(params = {}) ⇒ Object

Convert Markdown text to intermediate object.

Parameters:

  • params (Hash) (defaults to: {})

    A hash containing the Markdown extensions which the parser will identify. The following extensions are accepted.

Options Hash (params):

  • :on_error (Symbol)

    If :raise, then raise error.



55
56
57
58
59
60
# File 'lib/malt/engines/maruku.rb', line 55

def create_engine(params={})
  text = parameters(params, :text)
  opts = engine_options(params)

  ::Maruku.new(text, opts)
end

#render(params = {}) ⇒ Object

Convert Markdown text to HTML text.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :text (String)

    Template text

  • :to (String, Symbol) — default: 'html'

    Type or file extension to convert template into.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/malt/engines/maruku.rb', line 23

def render(params={})
  into, text, part = parameters(params, :to, :text, :partial)

  engine = prepare_engine(params)

  case into
  when :html, nil
    if part
      engine.to_html
    else
      engine.to_html_document
    end
  when :latex #, :pdf
    if part
      engine.to_latex
    else
      engine.to_latex_document
    end
  else
    super(params)
  end
end