[docbook-apps] Minimum TOC depth?

2014-08-13 Thread Ken Morse
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


Re: [docbook-apps] Minimum TOC depth?

2014-08-13 Thread Bob Stayton

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) gt; 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
b...@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


-
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org