Class: Rote::Filters::RedCloth
- Inherits:
-
TextFilter
- Object
- TextFilter
- Rote::Filters::RedCloth
- Defined in:
- lib/rote/filters/redcloth.rb
Overview
Page filter that converts plain-text formatting to HTML using RedCloth. This allows both Textile and Markdown formatting to be used with any page.
Instance Attribute Summary
Attributes inherited from TextFilter
Instance Method Summary collapse
- #handler(text, page) ⇒ Object
-
#initialize(*redcloth_opts) ⇒ RedCloth
constructor
Create a new filter instance.
Methods inherited from TextFilter
Constructor Details
#initialize(*redcloth_opts) ⇒ RedCloth
Create a new filter instance. The supplied options are passed directly to RedCloth. The most common are :textile and :markdown - See RedCloth docs for a full list.
If no options are supplied, :textile is assumed.
25 26 27 28 29 |
# File 'lib/rote/filters/redcloth.rb', line 25 def initialize(*redcloth_opts) super() @redcloth_opts = redcloth_opts raise "RedCloth is not available" unless defined?(RedCloth) end |
Instance Method Details
#handler(text, page) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rote/filters/redcloth.rb', line 31 def handler(text,page) rc = ::RedCloth.new(text) # hack around a RedCloth warning rc.instance_eval { @lite_mode = false } rc.to_html(*@redcloth_opts) end |