[kramdown-users] Creating ToC outside the document

Thomas Leitner t_leitner at gmx.at
Mon Oct 15 13:25:10 UTC 2012

On 2012-10-15 18:34 +0530 Sandeep Laxman wrote:
> Hi Thomas,
> I was trying to use the same but I am still getting errors. I guess
> something is wrong with my code. My kramdown document is stored in
> @book.content.
> When I do the following:
> Kramdown::Converter::Toc.new(@book.content)

You have to do:

  doc = Kramdown::Document.new(@book.content)
  toc = doc.to_toc

The `toc` object then holds the (nested) elements of the table of
contents. You can output the table of contents in any way you like!
I.e. there is no predefined format (like nested `<ul>` lists).

Best regards,

More information about the kramdown-users mailing list