Re: Collapsable/Expandable TOC

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/Collapsable-Expandable-TOC-tp789p8228.html

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,

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