Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 31c8a17d99
Fetching contributors…

Cannot retrieve contributors at this time

executable file 30 lines (23 sloc) 0.767 kb
## test code for cleanuping up text
# note: do not use: str.gsub(/<\/?[^>]*>/, "")
# because improper HTML causes bad results
require 'rubygems'
require 'action_controller'
sanitizer = HTML::FullSanitizer.new
puts sanitizer.sanitize("<h1>test 1 2 3</h1>")
puts sanitizer.sanitize("<h1>test 1 2 3</h1>regular text")
puts sanitizer.sanitize("<h1>test 1 2 3</h1>\nregular text")
def clean_up text
def remove_extra_whitespace text
puts text
text = text.strip.gsub("\n", ' ').gsub("\t", ' ')
5.times { text.gsub!(' ', ' ') }
text
end
text.gsub!('>', '> ')
if text.index('<')
text = HTML::FullSanitizer.new.sanitize(text)
end
remove_extra_whitespace(text)
end
#puts clean_up("<h1>header 1</h1>This is\n <b>a test \t 1 2 3. ")
Jump to Line
Something went wrong with that request. Please try again.