Created
September 16, 2008 21:46
-
-
Save ELLIOTTCABLE/11141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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