Skip to content

Commit

Permalink
Fixing dependency on Loofah::Helpers in a core method.
Browse files Browse the repository at this point in the history
Fixes #75. #OSL
  • Loading branch information
flavorjones committed Aug 22, 2014
1 parent 2a077ae commit 9ce1b3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions 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:
Expand Down
4 changes: 4 additions & 0 deletions lib/loofah.rb
Expand Up @@ -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
3 changes: 2 additions & 1 deletion lib/loofah/helpers.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/loofah/instance_methods.rb
Expand Up @@ -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

Expand Down

0 comments on commit 9ce1b3a

Please sign in to comment.