[
https://issues.apache.org/jira/browse/SOLR-10612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15999966#comment-15999966
]
Cassandra Targett commented on SOLR-10612:
------------------------------------------
I discovered a way we could do this today.
The theme TOC has support already for disabling it on a per-page basis
({{_layouts/page.html}} has an {{unless page.toc == false}} statement at line
37). If you add {{:page-toc: false}} to any page, it will not generate the
table of contents.
The problem is that the asciidoctor syntax for adding a TOC is {{:toc:}}, which
is page-level so basically interpreted as {{:page-toc:}}, negating the previous
statement.
If we change the unless statement to something like {{unless page.jstoc ==
false}}, then we can declare the following in the page:
{code}
= Language Analysis
:page-shortname: language-analysis
:page-permalink: language-analysis.html
:page-jstoc: false
:toc:
:toclevels: 1
{code}
This generates a single-level-deep TOC (see screenshot). It still uses the JS
template to render it (so, we don't gain back control of where to put the TOC,
which asciidoctor natively supports several options for, but I suspect this is
partly a limitation in the jekyll-asciidoctor gem).
It does not add any TOC to the PDF, because a rule there prevents it.
> make ':toclevels:' work in our jekyll templates
> -----------------------------------------------
>
> Key: SOLR-10612
> URL: https://issues.apache.org/jira/browse/SOLR-10612
> Project: Solr
> Issue Type: Sub-task
> Security Level: Public(Default Security Level. Issues are Public)
> Components: documentation
> Reporter: Hoss Man
> Assignee: Hoss Man
> Attachments: lang-analysis-1-level-toc.png
>
>
> asciidoc has a concept called {{:toclevels:}} which is suppose to determine
> which how deep down a page's section/header depth the generated table of
> contents will show -- ie: some LONG pages have a huge number of level 2
> headings, and on those pages we only want to show level 1.
> but in jekyll, asciidoctor isn't responsible for generating the TOC --
> instead it's done by some javascript (which is better for a variety of
> reasons) and at the moment this javascript doesn't know anything about
> {{:toclevels:}}
> But it should be possible to tweak our rendering templates to include
> {{:toclevels:}} as an attribute in the generated HTML, and then we can tweak
> the javascript call made to generate the TOC so that it respects it on a
> per-page basis
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]