Problem with ::toc[] and custom HTML template

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

Problem with ::toc[] and custom HTML template

DrAscii
test.adoc

= Test
:toc: macro

abc

toc::[]

abc

Command

asciidoctor --trace -T asciidoctor-backends/erb/html5 test.adoc

or

asciidoctor --trace -T asciidoctor-backends/haml/html5 test.adoc

or

asciidoctor --trace -T asciidoctor-backends/slim/html5 test.adoc

Result (asciidoctor --trace -T asciidoctor-backends/erb/html5 test.adoc)

Traceback (most recent call last):
        27: from /usr/local/bin/asciidoctor:23:in `<main>'
        26: from /usr/local/bin/asciidoctor:23:in `load'
        25: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/bin/asciidoctor:15:in `<top (required)>'
        24: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:111:in `invoke!'
        23: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:111:in `each'
        22: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:128:in `block in invoke!'
        21: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `convert_file'
        20: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `open'
        19: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `block in convert_file'
        18: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:118:in `convert'
        17: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:951:in `convert'
        16: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/converter/composite.rb:28:in `convert'
        15: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/converter/template.rb:107:in `convert'
        14: from /var/lib/gems/2.5.0/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'
        13: from /var/lib/gems/2.5.0/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'
        12: from /var/lib/gems/2.5.0/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'
        11: from asciidoctor-backends/erb/html5/document.html.erb:144:in `__tilt_46916425557440'
        10: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:1020:in `content'
         9: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `content'
         8: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `map'
         7: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:84:in `block in content'
         6: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/abstract_block.rb:75:in `convert'
         5: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/converter/composite.rb:28:in `convert'
         4: from /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/converter/template.rb:109:in `convert'
         3: from /var/lib/gems/2.5.0/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'
         2: from /var/lib/gems/2.5.0/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'
         1: from /var/lib/gems/2.5.0/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'
/asciidoctor-backends/erb/html5/block_toc.html.erb:16:in `__tilt_46916425557440': undefined method `convert_with_options' for #<Asciidoctor::Converter::CompositeConverter:0x000055572a698968> (NoMethodError)

Additional information

I've just downloaded the directory
asciidoctor-backends
from GitHub without modifying anything.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ::toc[] and custom HTML template

abelsromero
I am sorry to say, as per this comment https://github.com/asciidoctor/asciidoctor-backends/issues/124#issuecomment-305276934 `asciidoctor-backends` is for reference and example, and it seems contains some inconsitencies with last Asciidoctor version.

The error you see "undefined method `convert_with_options'" is because the method no longer exists in the Asciidoctor::Converter, you can use `convert` instead https://github.com/asciidoctor/asciidoctor/blob/88bc891d6a0143f3a2142f41d29cabe3cb21fe3f/lib/asciidoctor/converter.rb#L71.
After fixing this, I had to apply another change in "block_outline.html.slim" to change usage of `DEFAULT_TOCLEVELS` also.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ::toc[] and custom HTML template

wesruv
Any chance there's an example of this working? E.g. are the template files for docs.asciidoctor.org publicly viewable, or are there sites with their templates publicly viewable?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ::toc[] and custom HTML template

wesruv
Of course after I posted I found an example (I think?)

converter.convert @document, 'outline'
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ::toc[] and custom HTML template

abelsromero
There's this repo with examples https://github.com/asciidoctor/asciidoctor-backends, but it's for example, not an official reference.

Also, if you struggle and have more questions, the best is to address in https://asciidoctor.zulipchat.com/, there's more activity there.