lib/jkl/text_client.rb in jakal-0.2.0 vs lib/jkl/text_client.rb in jakal-0.2.1
- old
+ new
@@ -1,12 +1,16 @@
module Jkl
module Text
class << self
def plain_text(document, words_on_line = 5)
- remove_short_lines(strip_all_tags(remove_script_tags(document)), words_on_line)
+ CGI::unescapeHTML(
+ remove_short_lines(
+ strip_all_tags(
+ remove_script_tags(document)), words_on_line))
end
+ alias :sanitize :plain_text
def strip_all_tags(text)
text.gsub(/<\/?[^>]*>/, "")
end
@@ -24,15 +28,13 @@
end
def remove_short_lines(text, words_on_line = 5)
text = text.gsub(/\s\s/, "\n")
str = ""
- # remove short lines - ususally just navigation
- text.split("\n").each do |l|
- str << l unless l.count(" ") < words_on_line
+ text.split("\n").each do |line|
+ str << "#{line}\n" unless line.count(" ") < words_on_line
end
str
end
-
end
end
end