# encoding: utf-8
module Sanitizer
# HTMLEntris
@@htmle = HTMLEntities.new
# All self.methods
class << self
# Sanitize to clean text
def sanitize!(text)
strip_tags!(text)
clean_spaces!(text)
text.replace html_encode(text)
text
end
def sanitize(text)
sanitize! text.dup
end
# Clean retundant spaces
def clean_spaces!(text)
text.gsub!(/\s+/, " ")
text.strip!
text
end
def clean_spaces(text)
clean_spaces! text.dup
end
# remove comments
def strip_comments!(text)
text.gsub!(/(\<\!\-\-\b*[^\-\-\>]*.*?\-\-\>)/ui, "")
text.gsub!(/(\<\s?\!--.*\s?--\>)/uim, "")
text
end
def strip_comments(text)
strip_comments! text.dup
end
# Remove all