class String def truncate(width) self[0, width] end def convert_entities self.gsub(/>/, '>').gsub(/</, '<') end end