class Downr::Markdown
This class is a wrapper for the render method on Redcarpet
@attr [Redcarpet::Markdown] renderer
Attributes
renderer[RW]
Public Class Methods
new()
click to toggle source
Creates a new Markdown
object
# File lib/downr/markdown.rb, line 19 def initialize @@options = Downr.configuration.options render = Render.new(@@options) @@renderer = Redcarpet::Markdown.new(render, @@options) end
render(text)
click to toggle source
Renders markdown @param [String] text
@return [String] html
# 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)
click to toggle source
Sanitizes html input removing tags that are considered “unsafe”
@param [String] html
@return [String] html
# File lib/downr/markdown.rb, line 47 def self.sanitize_html(html) HTML::Pipeline::SanitizationFilter.new(html).call.to_s end