Method: Arrow::HTMLToken#escape_html
- Defined in:
- lib/arrow/htmltokenizer.rb
#escape_html(string) ⇒ Object
Escape special characters in the given string for display in an HTML inspection interface. This escapes common invisible characters like tabs and carriage-returns in additional to the regular HTML escapes.
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/arrow/htmltokenizer.rb', line 148 def escape_html( string ) return "nil" if string.nil? string = string.inspect unless string.is_a?( String ) string. gsub(/&/, '&'). gsub(/</, '<'). gsub(/>/, '>'). gsub(/\r?\n/, %Q{<br />\n}). gsub(/\t/, ' ') end |