Collapsable/Expandable TOC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Collapsable/Expandable TOC

daveb
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.
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

mojavelinux
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.

Dave.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

max990
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
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

mojavelinux
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

Best Regards,

-Dan

On Tue, Sep 8, 2020 at 11:55 PM max990 [via Asciidoctor :: Discussion] <[hidden email]> wrote:
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


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789p8227.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

max990
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?
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

mojavelinux
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.
But I don't see outline.html.erb. Do you know where I can find default content of it?


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789p8229.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

max990
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

Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

mojavelinux
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.

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!




If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789p8231.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Collapsable/Expandable TOC

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:
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.

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!




If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789p8231.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789p8232.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux