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