Class: Nanoc::Filters::Redcarpet
- Inherits:
-
Nanoc::Filter
- Object
- Context
- Nanoc::Filter
- Nanoc::Filters::Redcarpet
- Defined in:
- lib/nanoc/filters/redcarpet.rb
Overview
Constant Summary
Constant Summary
Constants inherited from Nanoc::Filter
Nanoc::Filter::TMP_BINARY_ITEMS_DIR
Instance Attribute Summary
Attributes inherited from Nanoc::Filter
Instance Method Summary (collapse)
-
- (Object) run(content, params = {})
Runs the content through Redcarpet.
Methods inherited from Nanoc::Filter
#depend_on, #filename, from_binary?, #initialize, #output_filename, requires, setup, #setup_and_run, to_binary?, type
Methods included from PluginRegistry::PluginMethods
#all, #identifier, #identifiers, #named, #register
Methods inherited from Context
Constructor Details
This class inherits a constructor from Nanoc::Filter
Instance Method Details
- (String) run(content, params = {}) - (String) run(content, params = {})
Runs the content through Redcarpet. This method optionally takes processing options to pass on to Redcarpet.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/nanoc/filters/redcarpet.rb', line 42 def run(content, params = {}) if ::Redcarpet::VERSION > '2' = params[:options] || {} renderer_class = params[:renderer] || ::Redcarpet::Render::HTML = params[:renderer_options] || {} if .is_a?(Array) warn 'WARNING: You are passing an array of options to the :redcarpet filter, but Redcarpet 2.x expects a hash instead. This will likely fail.' end if renderer_class == ::Redcarpet::Render::HTML_TOC renderer = renderer_class.new else renderer = renderer_class.new() end ::Redcarpet::Markdown.new(renderer, ).render(content) else = params[:options] || [] ::Redcarpet.new(content, *).to_html end end |