# File lib/feedparser/text-output.rb, line 7 def html2text(wrapto = false) text = self.clone # parse HTML p = FeedParser::HTML2TextParser::new(true) p.feed(text) p.close text = p.savedata # remove leading and trailing whilespace text.gsub!(/\A\s*/m, '') text.gsub!(/\s*\Z/m, '') # remove whitespace around \n text.gsub!(/ *\n/m, "\n") text.gsub!(/\n */m, "\n") # and duplicates \n text.gsub!(/\n\n+/m, "\n\n") # and remove duplicated whitespace text.gsub!(/[ \t]+/, ' ') # finally, wrap the text if requested return wrap_text(text, wrapto) if wrapto text end