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


195
196
197
198
# File 'lib/bitclust/ridatabase.rb', line 195

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

.unescape(str) ⇒ Object


204
205
206
207
# File 'lib/bitclust/ridatabase.rb', line 204

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