Hi all!
I would like to render als TOC using a little string (e. g. `[TOC]) in a pure markdown file.
This is what I’ve tried so far using your code:
helpers do
def table_of_contents
if ['[TOC]', '{:toc}'].include?(current_page)
content = File.read(current_page.source_file)
toc_renderer = Redcarpet::Render::HTML_TOC.new
markdown = Redcarpet::Markdown.new(toc_renderer, nesting_level: 2)
markdown.render(content)
end
end
end
No success so far. It would be great, if some could help me.