[kramdown-users] Creating ToC outside the document

Sandeep Laxman sandeep.laxman at gmail.com
Tue Oct 16 08:37:04 UTC 2012


Thanks Thomas. I do have question though. As I understand it, the toc is a
tree. Is there a kramdown api call that I can use to convert the toc to
html code (separately outside the document) or will i need to write a
custom logic simliar to
http://kramdown.rubyforge.org/rdoc/Kramdown/Converter/Html.html#method-i-generate_toc_tree

Thanks again!

On Tue, Oct 16, 2012 at 1:53 PM, Thomas Leitner <t_leitner at gmx.at> wrote:

> On 2012-10-15 08:51 -0700 Matt Neuburg wrote:
> >
> > On Oct 15, 2012, at 6:25 AM, Thomas Leitner <t_leitner at gmx.at> wrote:
> >
> > > 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).
> > >
> >
> >
> > I don't see any of this in the documentation…! m.
>
> This is described in the API documentation at
> http://kramdown.rubyforge.org/rdoc/
>
> Best regards,
>   Thomas
> _______________________________________________
> kramdown-users mailing list
> kramdown-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/kramdown-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/kramdown-users/attachments/20121016/242cc1f2/attachment.html>


More information about the kramdown-users mailing list