Class: FacebookWall::FeedEntryFilters::Paragraphizer
- Inherits:
-
FeedEntryFilter
- Object
- FeedEntryFilter
- FacebookWall::FeedEntryFilters::Paragraphizer
- Defined in:
- lib/facebook_wall/feed_entry_filters/paragraphizer.rb
Overview
Builds HTML paragraphs from groups of text separated by multiple BR
tags. For example:
First paragraph<br /> <br /> Second paragraph<br/><br/><br/>Something inserted<br/>by Facebook
would be replaced with:
<p>First paragraph</p><p>Second paragraph</p><p>Something inserted<br/>by Facebook</p>
Instance Method Summary collapse
Instance Method Details
#apply!(feed_entry) ⇒ Object
8 9 10 11 12 |
# File 'lib/facebook_wall/feed_entry_filters/paragraphizer.rb', line 8 def apply!(feed_entry) plain_paragraphs = Paragraphizer.normalize_line_breaks(feed_entry.description).split(/(?:<br\/>\s*){2,}/) paragraphized = plain_paragraphs.collect{|plain_paragraph| "<p>#{plain_paragraph}</p>"}.join feed_entry.description = paragraphized end |