Module: Sintaxi::CodeFiltered::InstanceMethods
- Defined in:
- lib/code_filtered.rb
Instance Method Summary collapse
- #filter_columns ⇒ Object
- #sanitize(text, filter = "Plain HTML") ⇒ Object
- #sanitize_code(text) ⇒ Object
Instance Method Details
#filter_columns ⇒ Object
28 29 30 31 32 |
# File 'lib/code_filtered.rb', line 28 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
34 35 36 37 38 39 40 |
# File 'lib/code_filtered.rb', line 34 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
42 43 44 45 46 47 |
# File 'lib/code_filtered.rb', line 42 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 |