docbook-apps

  • 1.  Minimum TOC depth?

    Posted 08-13-2014 16:13
    Has anyone figured out a way to have a *minimum* TOC depth? With HTML
    output, I'll sometimes see a page that has a single TOC that simply points
    to the first section -- in that case, it would be really nice to just skip
    the TOC.

    (On a related note, with chunk.first.sections turned off, even when there
    are multiple items in the TOC, the first item will often be a link to
    something that's already visible on the page, which is sometimes not all
    that useful).

    Thanks,
    Ken



  • 2.  Re: [docbook-apps] Minimum TOC depth?

    Posted 08-13-2014 17:05
    Hi Ken,
    To clarify the terminology, you are describing here a minimum *length*
    of TOC. The depth refers to the degree of nesting of sections.

    There is no param that controls whether a TOC is omitted if its length
    is below some minumum, but I can see how it would be a good idea.

    For HTML output, you could customize the template named 'make.toc' in
    html/autotoc.xsl. Where it says:

    <xsl:if test="$nodes">

    you could use something like:

    <xsl:if test="count($nodes) > 1">

    But $nodes contains only the first level entries for that TOC, not any
    children of those nodes (which are handled by the 'subtoc' template).
    So if you have a single section but it contains many subsections and
    your TOC depth is two or more, then this test would skip the TOC when
    there was more than one entry in the TOC. To be more precise, the
    template would have to count the entries in all levels of the TOC, which
    is a bit trickier.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net

    On 8/13/2014 9:12 AM, Ken Morse wrote:
    > Has anyone figured out a way to have a /minimum/ TOC depth? With HTML
    > output, I'll sometimes see a page that has a single TOC that simply
    > points to the first section -- in that case, it would be really nice to
    > just skip the TOC.
    >
    > (On a related note, with chunk.first.sections turned off, even when
    > there are multiple items in the TOC, the first item will often be a link
    > to something that's already visible on the page, which is sometimes not
    > all that useful).
    >
    > Thanks,
    > Ken