Class: String
Constant Summary collapse
- HTML_ESCAPE =
{ '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', }
Instance Method Summary collapse
- #color_diff ⇒ Object
-
#html_escape ⇒ Object
Returns a copy of
textwith ampersands, angle brackets and quotes escaped into HTML entities.
Instance Method Details
#color_diff ⇒ Object
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_escape ⇒ Object
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 |