Class: HTML::Pipeline::BbcodeFilter

Inherits:
TextFilter
  • Object
show all
Defined in:
lib/html/pipeline/bbcode_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, context = {}, result = nil) ⇒ BbcodeFilter

Returns a new instance of BbcodeFilter.



6
7
8
9
10
# File 'lib/html/pipeline/bbcode_filter.rb', line 6

def initialize(text, context = {}, result = nil)
  super text, context, result
  @context = context
  @text = @text.gsub "\r", ''
end

Instance Method Details

#call ⇒ Object



12
13
14
15
16
# File 'lib/html/pipeline/bbcode_filter.rb', line 12

def call
  html = BBCoder.new(@text).to_html.gsub(/\n|\r\n/, '<br />')
  html.rstrip!
  "<p>#{html}</p>"
end