Class: FacebookWall::FeedEntryFilters::Paragraphizer

Inherits:
FeedEntryFilter show all
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

Second paragraph


Something inserted
by Facebook would be replaced with:

First paragraph

Second paragraph

Something inserted
by Facebook

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