Module: Sintaxi::MerbCanFilter::InstanceMethods
- Defined in:
- lib/merb_can_filter.rb
Instance Method Summary collapse
- #filter_columns ⇒ Object
- #sanitize(text, filter = "Plain HTML") ⇒ Object
- #sanitize_code(text) ⇒ Object
Instance Method Details
#filter_columns ⇒ Object
24 25 26 27 28 |
# File 'lib/merb_can_filter.rb', line 24 def filter_columns unfiltered.each do |column| send "#{column}_html=", sanitize(send(column).to_s.dup, self.filter) end end |
#sanitize(text, filter = "Plain HTML") ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/merb_can_filter.rb', line 30 def sanitize(text, filter="Plain HTML") textilized = case filter when "Markdown" then sanitize_code(BlueCloth.new(text)).to_html when "Textile" then sanitize_code(RedCloth.new(text).to_html) else sanitize_code(text.dup) end end |
#sanitize_code(text) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/merb_can_filter.rb', line 38 def sanitize_code(text) text.scan(/(<code\:([a-z].+?)>(.+?)<\/code>)/m).each do |match| text.gsub!(match[0],CodeRay.scan(match[2], match[1].to_sym).div(:css => :class)) end text end |