Skip to content

Instantly share code, notes, and snippets.

@martinrehfeld
Forked from jamesgolick/gist:345040
Created May 9, 2010 18:29
Show Gist options
  • Save martinrehfeld/395331 to your computer and use it in GitHub Desktop.
Save martinrehfeld/395331 to your computer and use it in GitHub Desktop.
Syntax highlighting for Ruby code (webby helper)
require 'syntax/convertors/html'
require 'uv'
module Code
BACKGROUND_COLOR = '#2B2B2B'
COLOR = '#E6E1DC'
COLORS = {
:keyword => '#CC7833',
:symbol => '#6E9CBE',
:constant => '#DA4939',
:attribute => '#D0D0FF',
:string => '#A5C261'
}
def code(opts={}, &block)
text = capture_erb(&block)
return if text.empty?
text.gsub!("<%%", "<%")
the_code = Uv.parse( text, "xhtml", opts[:type] || "ruby", false, "twilight")
concat_erb(the_code, block.binding)
end
end
Webby::Helpers.register(Code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment