Class: Malt::Engine::Redcarpet
- Defined in:
- lib/malt/engines/redcarpet.rb
Overview
Redcarpet Markdown implementation.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#create_engine(params = {}) ⇒ Object
Convert Markdown text to intermediate object.
-
#create_engine_1x(params = {}) ⇒ Object
For Recarpet v1.x.
-
#render(params = {}) ⇒ Object
Convert Markdown text to HTML text.
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.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/malt/engines/redcarpet.rb', line 83 def create_engine(params={}) return create_engine_1x(params) if ::Redcarpet::VERSION < '2' into, toc = parameters(params, :to, :toc) opts = (params) case into when :man, :manpage renderer = ::Redcarpet::Render::ManPage else if toc renderer = ::Redcarpet::Render::HTML_TOC else renderer = ::Redcarpet::Render::HTML end end cached(into, toc, opts) do ::Redcarpet::Markdown.new(renderer) end end |
#create_engine_1x(params = {}) ⇒ Object
For Recarpet v1.x.
107 108 109 110 111 112 113 |
# File 'lib/malt/engines/redcarpet.rb', line 107 def create_engine_1x(params={}) text = parameters(params, :text) cached(text) do ::Redcarpet.new(text) #, engine_options(params)) end end |
#render(params = {}) ⇒ Object
Convert Markdown text to HTML text.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/malt/engines/redcarpet.rb', line 23 def render(params={}) into, text = parameters(params, :to, :text) case into when :html, nil # :man, :manpage if ::Redcarpet::VERSION < '2' prepare_engine(params).to_html else prepare_engine(params).render(text) end else super(params) end end |