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:
https://github.com/richleland/pygments-css. You may need to configure the CSS class to have .highlight
as base class.
You can add a nice code block like this:
```ruby def index @cars = Car.all respond_to do |format| format.html # index.html.erb format.json { render json: @cars } end end ```
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request