When using toc2 it would be very nice if toc levels could be expanded or collapsed to make navigation easier. With a very long toc, such as with the ever improving users manual, it is not always easy to find what you are looking.
Dave. |
Administrator
|
Agreed. We'll definitely want to use a well-tested JavaScript component for this (since we don't want to be in the business of reinventing that wheel). An accordion with entries for each part may work well here (without introducing too much annoyance). Would you be willing to file an issue? Also, keep in mind that it's possible to implement this today with a custom document template (or maybe even a docinfo file). Obviously, having support out of the box is ideal, you still have the option of splicing it in without having to wait for a release. -Dan On Thu, Oct 10, 2013 at 6:39 AM, daveb [via Asciidoctor :: Discussion] <[hidden email]> wrote: When using toc2 it would be very nice if toc levels could be expanded or collapsed to make navigation easier. With a very long toc, such as with the ever improving users manual, it is not always easy to find what you are looking. Dan Allen | http://google.com/profiles/dan.j.allen |
Hi,
You said it's possible to implement custom html template for toc? I see block_toc.html.erb but I can't see <ul>, <li>, .. to change them (add class, ..) Where can I do that? Thanks |
Administrator
|
The converter defines a dedicated block named "outline" that handles the generation of the TOC. (see https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L341-L378) You'd either need to override this method in Ruby using a custom converter or define a template named "outline.html.erb" and pass the directory with that template to the asciidoctor command (using the -T flag). Here's how to override the method in Ruby: class MyHTMLConverter < (Asciidoctor::Converter.for 'html5') register_for :html5 def convert_outline node, opts = {} # insert logic here end end To learn how to make and use templates, see these resources: https://github.com/asciidoctor/asciidoctor.org/issues/80 https://github.com/asciidoctor/jekyll-asciidoc#customizing-the-generated-html (ignore the references to Jekyll) Best Regards, -Dan On Tue, Sep 8, 2020 at 11:55 PM max990 [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi, -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
Thanks! For the moment I edit erb files to customize my html.
But I don't see outline.html.erb. Do you know where I can find default content of it? |
Administrator
|
There is no default content (at least there was never a template made for it). I pointed you to the logic in the built-in HTML converter, which relies heavily on Ruby. Best Regards, -Dan On Wed, Sep 9, 2020 at 12:18 AM max990 [via Asciidoctor :: Discussion] <[hidden email]> wrote: Thanks! For the moment I edit erb files to customize my html. -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
This post was updated on .
Thanks, i try to convert https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L341-L378 to erb file.
When I put static text, it's ok my test is displayed in my html document. Now I try to generate the toc. I'm not very comfortable with ruby at all (i'm mainly java developer). When I try simply to do this (as done in ruby code): <%#encoding:UTF-8%> <% sections = node.sections %> I got : java.lang.NegativeArraySizeException at org.jruby.util.ByteList.ensure(ByteList.java:344) at org.jruby.util.io.EncodingUtils.strBufCat(EncodingUtils.java:1708)<quote author="mojavelinux"> Does node variable is not available when using erb file? how could I fix this? How can i create my loop to display all my toc? Thanks a lot for your reactivity! PS: I use java library asciidoctorj to generate my html from asciidoc |
Administrator
|
Unfortunately, I don't have time to help you develop this template right now. You might try to ask in the chat channel where more people hang out. https://gitter.im/asciidoctor/asciidoctor. What I will say is that I personally do not like ERB. I recommend using slim instead. It's much easier to program in. It has been a long time since I used ERB and I don't remember all the rules. Best Regards, -Dan On Wed, Sep 9, 2020 at 3:49 AM max990 [via Asciidoctor :: Discussion] <[hidden email]> wrote: Thanks, i try to convert https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L341-L378 to erb file. -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
Administrator
|
There are also implementations of a collapsable toc floating around. I don't have the link off the top of my head, but I do know that they exist. For example: https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html -Dan On Wed, Sep 9, 2020 at 4:17 AM mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
-- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
Free forum by Nabble | Edit this page |