ddfreyne/nanoc — pull request #200 by dwoll (2013-01-22 17:06:24+00:00)
Title: Add TOC-support for Redcarpet 2

nanoc currently does not support including a table of contents with the redcarpet.rb filter. Setting `:renderer_options => { :with_toc_data => true }` creates an html file with all anchors, but without the actual TOC. To include the TOC itself, Redcarpet needs two passes ([example](http://dev.af83.com/2012/02/27/howto-extend-the-redcarpet2-markdown-lib.html)):

* the first pass uses the HTML_TOC renderer to create only the TOC
* the second pass uses the HTML renderer to create the html body with all anchors
* TOC and body need to be joined

I suggest a boolean option `:with_toc` to request the TOC itself. The proposed patch adds the TOC when all relevant options are set correctly (`:with_toc => true`, `:renderer_options => { :with_toc_data => true }`) and the renderer is `::Redcarpet::Render::HTML`.