Class: HTML::Pipeline::BbcodeFilter
- Inherits:
-
TextFilter
- Object
- TextFilter
- HTML::Pipeline::BbcodeFilter
- Defined in:
- lib/html/pipeline/bbcode_filter.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text, context = {}, result = nil) ⇒ BbcodeFilter
constructor
A new instance of BbcodeFilter.
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 |