Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi!
I'm trying to display the toc content in a particular place. I've my page.adoc with toc(s) attributes specified and I want to display the toc block at the right of the page.(like the excellent guide Arquillian site) I use the layout page of Awestruct and the ~ content way to display the generated text from page.adoc. My code : my layout base-souscription.html.haml ... %body .navbar.navbar-fixed-top .navbar-inner .container %a.brand{ :href=>"/" } Home .container .row .span9 ~ content .span3 Here I'd like the toc of the current page... ... my adoc file = Souscription Just me :awestruct-layout: base-souscription :toc: :toc-placement: manual :toc-title: Questions toc::[] == Chapter 1 the first chapter.. == Chapter 2 The second chapter Is there a solution? Thanks Stéphane |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
To my knowledge the only way you'd be able to do this is with some javascript to remove the fragment containing the TOC and place it somewhere else. awestruct has no idea about the contents of the pages before / or after they're rendered. Actually, you could create an awestruct extension to do the same thing as the javascript. Use Nokogiri to do the work. On Sun, Sep 8, 2013 at 1:54 PM, fleurystephane [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi! ... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
|
Stéphane, This is one of the features I'm looking forward to having in Awestruct. The feature is actually more generic than just solving the TOC problem. When an AsciiDoc document is parsed by Asciidoctor, it is loaded into an object model (call it an AST or DOM). I think that object model should be available to the layouts when the page is being constructed. This would allow the sidebar file in the main layout to render just the table of contents from the object model. It would also allow us to put other content extracted from the document into the sidebar. ...the fact that this isn't yet implemented doesn't mean it's not possible today. I believe there is a way for the sidebar to discover which file path is currently being rendered. In that case, you can simply invoke Asciidoctor directly inside the sidebar (or in an extension as Jason mentioned) to load the file again, then just step to the TOC block and render it. However, you look at it, just consider that you are treating the two locations on the page as two separate rendering events. The alternative is to place the TOC using JavaScript after the page has loaded (as we do on arquillian.org) but personally I find that to be pure hackery. It is possible to hit an in-between solution by rendering the TOC in a hidden div in the content, then pull it into the sidebar using JavaScript. That way, the integrity of the TOC is maintained. Here's how that last solution might work: :toc: :toc-placement: manual [#toc-container.hide] -- toc::[] -- <script> $('#sidebar').append($('#toc-container')); </scirpt> That's a reasonable solution to work with that won't require a ton of effort. Long-term, though, the best solution is to get Asciidoctor to emit the TOC as a secondary document into the sidebar region. I hope that gets you started! On Mon, Sep 9, 2013 at 9:45 AM, LightGuardjp [via Asciidoctor :: Discussion] <[hidden email]> wrote:
... [show rest of quote] -- Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Thanks Dan for your answer!
I think it will be a very usefull feature to have the toc part and the documentation separately in a web spirit. I'll use your solution with id toc placement. More I use these tools more I like them! Your help and your reactivity are very important! Thanks a lot! Stéphane |
Free forum by Nabble | Edit this page |