From 9ce1b3a25fb4cf8b0c2534dae16f6fe63d79fb58 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 22 Aug 2014 17:44:54 -0400 Subject: [PATCH] Fixing dependency on Loofah::Helpers in a core method. Fixes #75. #OSL --- CHANGELOG.rdoc | 7 +++++++ lib/loofah.rb | 4 ++++ lib/loofah/helpers.rb | 3 ++- lib/loofah/instance_methods.rb | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index e4b858ec..52020a5a 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,5 +1,12 @@ = Changelog +== 2.0.2 / unreleased + +Bug fixes: + +* Fix error with `#to_text` when Loofah::Helpers hadn't been required. #75 + + == 2.0.1 / 2014-08-21 Bug fixes: diff --git a/lib/loofah.rb b/lib/loofah.rb index 991b57a9..a3ccd932 100644 --- a/lib/loofah.rb +++ b/lib/loofah.rb @@ -74,5 +74,9 @@ def scrub_xml_document(string_or_io, method) Loofah.xml_document(string_or_io).scrub!(method) end + # A helper to remove extraneous whitespace from text-ified HTML + def remove_extraneous_whitespace(string) + string.gsub(/\n\s*\n\s*\n/,"\n\n") + end end end diff --git a/lib/loofah/helpers.rb b/lib/loofah/helpers.rb index f00ba52c..9f346951 100644 --- a/lib/loofah/helpers.rb +++ b/lib/loofah/helpers.rb @@ -33,9 +33,10 @@ def sanitize_css style_string # # A helper to remove extraneous whitespace from text-ified HTML + # TODO: remove this in a future major-point-release. # def remove_extraneous_whitespace(string) - string.gsub(/\n\s*\n\s*\n/,"\n\n") + Loofah.remove_extraneous_whitespace string end end diff --git a/lib/loofah/instance_methods.rb b/lib/loofah/instance_methods.rb index b33da0dc..c6366425 100644 --- a/lib/loofah/instance_methods.rb +++ b/lib/loofah/instance_methods.rb @@ -113,7 +113,7 @@ def text(options={}) # # => "\nTitle\n\nContent\n" # def to_text(options={}) - Loofah::Helpers.remove_extraneous_whitespace self.dup.scrub!(:newline_block_elements).text(options) + Loofah.remove_extraneous_whitespace self.dup.scrub!(:newline_block_elements).text(options) end end