Skip to content

Instantly share code, notes, and snippets.

@gsamokovarov
Created August 12, 2012 15:38
Show Gist options
  • Select an option

  • Save gsamokovarov/3332342 to your computer and use it in GitHub Desktop.

Select an option

Save gsamokovarov/3332342 to your computer and use it in GitHub Desktop.
Carmine Example - Image Formatter
require 'carmine'
# Opinionated client.
carmine = Carmine.new(
# Default to JavaScript lexing, if that's what the examples
# would be written in.
:lexer => :javascript,
# An image, so we can embed it into presentations.
:formatter => :png,
:options => {
# DejaVu Sans exists on the heroku server machine.
:font_name => 'DejaVu Sans Mono',
# Removes the line numbers, that's how I like my examples.
:line_numbers => false,
:font_size => 24
}
)
# Write the image somewhere and you are done.
File.open '/tmp/carmine.png', 'wb' do |file|
file.write carmine.colorize('console.log("Hello World!");')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment