Skip to content

Instantly share code, notes, and snippets.

@sentientwaffle
Created February 5, 2012 02:17
Show Gist options
  • Save sentientwaffle/1742049 to your computer and use it in GitHub Desktop.
Save sentientwaffle/1742049 to your computer and use it in GitHub Desktop.
Table of contents Jekyll plugin
# Be sure to set the following in the `_config.yml`.
#
# markdown: rdiscount
# rdiscount:
# extensions: [generate_toc]
#
module Jekyll
class MarkdownConverter
def convert(content)
setup
rd = RDiscount.new(content, *@rdiscount_extensions)
toc = %(<nav class="table-of-contents">
#{rd.toc_content}
</nav>)
return rd.to_html + toc
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment