using jekyll 2.0.3, I initially configured _config.yml with
markdown: kramdown
and I was able to add a table of contents as follows, in my example.md:
---
layout: page
title: Sample
---
{:toc}
## section 1
## section 2
however, I switched to redcarpet, see _config.yml:
markdown: redcarpet
redcarpet:
extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "strikethrough", "superscript", "with_toc_data"]
and now {:toc:}
does not work.
The documentation of redcarpet v2.2.2 (used by jekyll 2.0.3): https://github.com/vmg/redcarpet/blob/v2.2.2/README.markdown#and-its-like-really-simple-to-use
mentions :with_toc_data
, but I don't where/how to use this.
how can i display the table of contents using redcarpet?
The problem here is that :with_toc_data
is an option for an instance of the redcarpet renderer, and not a configuration extension.
Unfortunately, Jekyll doesn't seem to expose this renderer option, so I don't think you'll be able to use it. The docs say:
no renderer options aside from
smart
can be specified in Jekyll.
But you can use a table of contents jekyll plugin instead. A quick search returns a number of available options, and one is linked from the official Jekyll site.