From sandeep.laxman at gmail.com Mon Oct 15 11:46:36 2012 From: sandeep.laxman at gmail.com (Sandeep Laxman) Date: Mon, 15 Oct 2012 17:16:36 +0530 Subject: [kramdown-users] Creating ToC outside the document Message-ID: I started using kramdown just a few days ago. In my application, I want to show the ToC of kramdown document on a separate web page (where one can click on the link to the appropriate chapter). How can I do this? Thanks in advance!! - Sandeep -------------- next part -------------- An HTML attachment was scrubbed... URL: From t_leitner at gmx.at Mon Oct 15 12:23:34 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Mon, 15 Oct 2012 14:23:34 +0200 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: References: Message-ID: <20121015142334.64ef3972@noweto> On 2012-10-15 17:16 +0530 Sandeep Laxman wrote: > I started using kramdown just a few days ago. In my application, I > want to show the ToC of kramdown document on a separate web page > (where one can click on the link to the appropriate chapter). How can > I do this? You can use the [Converter::Toc class][1] to extract the TOC of a Kramdown document and display it anywhere and in any way you like. Best regards, Thomas [1]: http://kramdown.rubyforge.org/rdoc/Kramdown/Converter/Toc.html From sandeep.laxman at gmail.com Mon Oct 15 13:04:42 2012 From: sandeep.laxman at gmail.com (Sandeep Laxman) Date: Mon, 15 Oct 2012 18:34:42 +0530 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: <20121015142334.64ef3972@noweto> References: <20121015142334.64ef3972@noweto> Message-ID: 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) I get private method `new' called for Kramdown::Converter::Toc:Class How do I fix it? Thanks!! -Sandeep On Mon, Oct 15, 2012 at 5:53 PM, Thomas Leitner wrote: > On 2012-10-15 17:16 +0530 Sandeep Laxman wrote: > > I started using kramdown just a few days ago. In my application, I > > want to show the ToC of kramdown document on a separate web page > > (where one can click on the link to the appropriate chapter). How can > > I do this? > > You can use the [Converter::Toc class][1] to extract the TOC of a > Kramdown document and display it anywhere and in any way you like. > > Best regards, > Thomas > > [1]: http://kramdown.rubyforge.org/rdoc/Kramdown/Converter/Toc.html > _______________________________________________ > kramdown-users mailing list > kramdown-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/kramdown-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From t_leitner at gmx.at Mon Oct 15 13:25:10 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Mon, 15 Oct 2012 15:25:10 +0200 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: References: <20121015142334.64ef3972@noweto> Message-ID: <20121015152510.4c8914f4@noweto> 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 `
    ` lists). Best regards, Thomas From matt at tidbits.com Mon Oct 15 15:51:10 2012 From: matt at tidbits.com (Matt Neuburg) Date: Mon, 15 Oct 2012 08:51:10 -0700 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: <20121015152510.4c8914f4@noweto> References: <20121015142334.64ef3972@noweto> <20121015152510.4c8914f4@noweto> Message-ID: On Oct 15, 2012, at 6:25 AM, Thomas Leitner 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 `
      ` lists). > I don't see any of this in the documentation?! m. -- matt neuburg, phd = matt at tidbits.com, http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.com From t_leitner at gmx.at Tue Oct 16 08:23:38 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Tue, 16 Oct 2012 10:23:38 +0200 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: References: <20121015142334.64ef3972@noweto> <20121015152510.4c8914f4@noweto> Message-ID: <20121016102338.183550b9@noweto> On 2012-10-15 08:51 -0700 Matt Neuburg wrote: > > On Oct 15, 2012, at 6:25 AM, Thomas Leitner 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 `
        ` 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 From sandeep.laxman at gmail.com Tue Oct 16 08:37:04 2012 From: sandeep.laxman at gmail.com (Sandeep Laxman) Date: Tue, 16 Oct 2012 14:07:04 +0530 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: <20121016102338.183550b9@noweto> References: <20121015142334.64ef3972@noweto> <20121015152510.4c8914f4@noweto> <20121016102338.183550b9@noweto> Message-ID: 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 wrote: > On 2012-10-15 08:51 -0700 Matt Neuburg wrote: > > > > On Oct 15, 2012, at 6:25 AM, Thomas Leitner 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 `
          ` 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: From t_leitner at gmx.at Tue Oct 16 13:58:55 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Tue, 16 Oct 2012 15:58:55 +0200 Subject: [kramdown-users] Creating ToC outside the document In-Reply-To: References: <20121015142334.64ef3972@noweto> <20121015152510.4c8914f4@noweto> <20121016102338.183550b9@noweto> Message-ID: <20121016155855.73c398b6@noweto> On 2012-10-16 14:07 +0530 Sandeep Laxman wrote: > 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 Yes, the result of the toc converter is a tree consisting of custom :toc elements. You will need to write a custom logic, for now. -- Thomas