I prefer not to add these kinds of abstractions until I need them. Usually if I need to customize the options it will be to add or remove one option which will cause a lot of duplication. I think this kind of abstraction would be better, but too much to show in the episode.

Then you pass true/false options hash to modify the defaults. But the point is there are different ways to abstract this out, and we can't tell the best way without seeing how it needs to be customized.

Thanks for the screencast! When I use your example or the source code Nokogiri inserts HTML headers to the output of the syntax_highlighter method. I've fixed it by modifying the last line of that method.

Last night I've done some testing on an Ubuntu installation with the same results. I've modified the Nokogiri part so it will (hopefully) work on both installations. I've used the DocumentFragment class of Nokogiri.

@ Everyone trying to to this on Heroku I know I am late but I set up a new appspot app that uses the new version of Pygments and wrote a little blog post about how to use it at http://iamaust.in/posts/3.

I hope this helps people, now you can colorize things like coffeescript and sass for your rails 3.1 apps

@nathan le Ray you can pull from my github a modified version of albino that allows you to pass options to pygments. https://github.com/austinbv/albino. To use this version of albion in your gemfile just add

I started with the pre-release version of the new redcarpet gem and then went about modifying the helper you outlined in your screencast. Based on the following from the wiki for the gem

Rendering with the Markdown object is done through Markdown#render. Unlike in the RedCloth API, the text to render is passed as an argument and not stored inside the Markdown instance, to encourage reusability.

I tried to change your helper. This is the basics of what i tried. I clearly don't know enough to see what must be obvious to experienced programmers.

I've instantiate a Redcarpet object and call its 'render" method both inside the 'markdown' helper method. That value will be return to the view, but since it will be escaped you'll need to pass it through the 'raw' method so that it comes out as actual html.

Here's how I did it for a blog project using Rails 3.2 and Redcarpet 2.1 (minus the syntax highlighting). Some of the configuration options have been moved into the HTML renderer, while the more generic ones are still at the markdown layer:

Given the changes with Redcarpet, I was not able to get the steps in this Railscast to work. But, I used it to help me understand what I was looking at in figuring out what to do next. I got Redcarpet working with my Rails 4, RC1 blog. If you'd like steps, you can peek at it here:

Hey all I had a question about this, I'm using 3.2 and was wondering how would I implement live preview using the example above?? i have it working where when I enter the new information it reads the markdown

Notice they changed to sets of hashes for options. One hash of options for the Redcarpet::Render::HTML.new(options hash here)
and the second options hash for the Redcarpet::Markdown.new(renderer(this is where the renderer goes), markdown hash here). To understand, here are both without removing options into two variables.