Class: Linebreaker
- Inherits:
-
Object
- Object
- Linebreaker
- Defined in:
- lib/filters/linebreaker.rb
Overview
This filter just replaces single newlines with “<br />” tags.
Instance Method Summary collapse
-
#initialize(input) ⇒ Linebreaker
constructor
A new instance of Linebreaker.
- #to_html ⇒ Object
Constructor Details
#initialize(input) ⇒ Linebreaker
Returns a new instance of Linebreaker.
4 5 6 |
# File 'lib/filters/linebreaker.rb', line 4 def initialize(input) @input = input end |
Instance Method Details
#to_html ⇒ Object
8 9 10 11 12 |
# File 'lib/filters/linebreaker.rb', line 8 def to_html @input. gsub(/(\S)\n(\S)/, "\\1<br />\n\\2"). gsub(/(\S)\r\n(\S)/, "\\1<br />\n\\2") end |