Created
August 12, 2012 15:38
-
-
Save gsamokovarov/3332342 to your computer and use it in GitHub Desktop.
Carmine Example - Image Formatter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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