Class: String

Inherits:
Object show all
Defined in:
lib/plugins/html.rb

Constant Summary collapse

HTML_ESCAPE =
{ '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }

Instance Method Summary collapse

Instance Method Details

#color_diffObject



49
50
51
52
# File 'lib/plugins/html.rb', line 49

def color_diff
   self.gsub( /^(\+[^+].*)$/, '<ins style="background:#dfd;text-decoration:none;padding:0 10px;">\1</ins>').
   gsub( /^(\-[^-].*)$/, '<del style="background:#fdd;text-decoration:none;padding:0 10px;">\1</del>')
end

#html_escapeObject

Returns a copy of text with ampersands, angle brackets and quotes escaped into HTML entities.



45
46
47
# File 'lib/plugins/html.rb', line 45

def html_escape
   self.gsub(/[\"><&]/) { |s| HTML_ESCAPE[s] }
end