Class: Downr::Markdown
- Inherits:
-
Object
- Object
- Downr::Markdown
- Defined in:
- lib/downr/markdown.rb
Overview
This class is a wrapper for the render method on Redcarpet
Instance Attribute Summary collapse
-
#renderer ⇒ Redcarpet::Markdown
The current value of renderer.
Class Method Summary collapse
-
.render(text) ⇒ String
Renders markdown.
-
.sanitize_html(html) ⇒ String
Sanitizes html input removing tags that are considered "unsafe".
Instance Method Summary collapse
-
#initialize ⇒ Markdown
constructor
Creates a new Markdown object.
Constructor Details
#initialize ⇒ Markdown
Creates a new Markdown object
19 20 21 22 23 24 25 |
# File 'lib/downr/markdown.rb', line 19 def initialize @@options = Downr.configuration. render = Render.new(@@options) @@renderer = Redcarpet::Markdown.new(render, @@options) end |
Instance Attribute Details
#renderer ⇒ Redcarpet::Markdown
Returns the current value of renderer.
9 10 11 |
# File 'lib/downr/markdown.rb', line 9 def renderer @renderer end |
Class Method Details
.render(text) ⇒ String
Renders markdown
31 32 33 34 35 36 37 38 39 |
# File 'lib/downr/markdown.rb', line 31 def self.render text html = @@renderer.render(text) if(@@options[:sanitize_html].present? && @@options[:sanitize_html]) html = self.sanitize_html(html) end html end |
.sanitize_html(html) ⇒ String
Sanitizes html input removing tags that are considered "unsafe"
47 48 49 |
# File 'lib/downr/markdown.rb', line 47 def self.sanitize_html(html) HTML::Pipeline::SanitizationFilter.new(html).call.to_s end |