Skip to content
Add syntax highlighting to Middleman
Find file
Latest commit f00e30a Mar 11, 2013 @Linuus Updated readme
Failed to load latest commit information.
lib Fixes Mar 11, 2013
.gitignore Initial commit Mar 11, 2013
Gemfile Initial commit Mar 11, 2013
LICENSE.txt Initial commit Mar 11, 2013 Updated readme Mar 11, 2013
Rakefile Initial commit Mar 11, 2013
middleman-rouge.gemspec Initial commit Mar 11, 2013


The middleman-rouge gem adds syntax highlighting for Middleman using the Rouge library and Redcarpet markdown engine.


Add these lines to your application's Gemfile:

gem 'middleman-rouge'
gem "redcarpet"

And then execute:

$ bundle

Or install it yourself as:

$ gem install middleman-rouge
$ gem install redcarpet

Then add this to your config.rb file:

# Markdown

set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true, :smartypants => true

# Code highlighting

activate :rouge_syntax

Also, you need to add a CSS file to add some coloring. Rouge supports stylesheets created for Pygment. A nice collection of CSS files can be found here: You may need to configure the CSS class to have .highlight as base class.


You can add a nice code block like this:

def index
  @cars = Car.all

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @cars }


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.