Module: HTMLUtils

Included in:
Formatter
Defined in:
lib/bitclust/ridatabase.rb

Constant Summary collapse

ESC =
{
  '&' => '&',
  '<' => '&lt;',
  '>' => '&gt;',
  '"' => '&quot;'
}
UNESC =
ESC.invert

Class Method Summary collapse

Class Method Details

.escape(str) ⇒ Object



197
198
199
200
# File 'lib/bitclust/ridatabase.rb', line 197

def escape(str)
  t = ESC
  str.gsub(/[&"<>]/) {|s| t[s] }
end

.unescape(str) ⇒ Object



206
207
208
209
# File 'lib/bitclust/ridatabase.rb', line 206

def unescape(str)
  t = UNESC
  str.gsub(/&\w+;/) {|s| t[s] || s }
end