Skip to content

Instantly share code, notes, and snippets.

@kubo
Created February 19, 2012 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubo/1862300 to your computer and use it in GitHub Desktop.
Save kubo/1862300 to your computer and use it in GitHub Desktop.
module YARD
module Templates::Helpers
module HtmlHelper
BINARY_OPERATORS = %w{ + - * / % ** << >> & | <= < > >= <=> == === =~ }.collect { |t| CGI.escapeHTML(t) }
alias signature_pre_change_binary_operators signature
def signature(*args)
html = signature_pre_change_binary_operators(*args)
if %r{\((.+?)\) <strong>(.+?)</strong>\((.+?)\)} =~ html and BINARY_OPERATORS.include? $2
"%s(%s) &larr; self <strong>%s</strong> %s%s" % [$`, $1, $2, $3, $']
else
html
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment