Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created September 16, 2008 21:46
Show Gist options
  • Save ELLIOTTCABLE/11141 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/11141 to your computer and use it in GitHub Desktop.
%w[rubygems RedCloth stringray].each {|dep| require dep }
class RedCloth::TextileDoc
def clean(*rules)
# Fragile! Oh well. )-:
out = to_html.gsub(/<\/?[^>]*>/, "")
out.gsub(/\&\#[0123456789]+\;/, "?") # Replace entities with a question mark
end
end
String.send :include, StringRay
textile = RedCloth.new("A *TESTING* string!")
characters = words = textile.clean.length
words = textile.clean.to_stray.select {|w| w.is_a? StringRay::Word }.size
p [characters, words]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment