[daisy] Auto TOC for a document?
Vincent Mouton
vincent at postback.be
Thu Sep 13 13:09:43 CDT 2007
>
>
> Hi
> Many pages created in our Daisy site are quite big, and have multiple
> sections. Sometimes, its a pain to search for the relevant section. Is
> there
> a way a TOC can be automatically included, based on the h1, h2 and h3
> headers?
Shiva,
You could accomplish this through XSLT (i.e. in the skin).
Pretty rough, but you could loop through all tags at the first level inside
a part, and check for h1, h2, h3, ... tags
<!-- UNTESTED -->
<!-- This it the TOC -->
<ul>
<xsl:for-each select="d:parts/d:part[@name =
'PART_NAME_TO_DEFINE']/html/body/*[name() = 'h1' or name() = 'h2' or name()
= 'h2']">
<li><a href="#{name()}_{position()}"><xsl:apply-templates
/></a></li>
</xsl:for-each>
</ul>
<!--
This is the actual content rendering
You repeat this principle for all tags, to render the content, and
when encountering a heading, add an id="" attribute to it
-->
<xsl:for-each select="d:parts/d:part[@name =
'PART_NAME_TO_DEFINE']/html/body/*">
<xsl:if test="name() = 'h1' or name() = 'h2' or name() = 'h2'">
<a id="{name()}_{position()}"></a>
<!-- Even better would be to define the id attribute to the
h1, h2, ... tags itself -->
</xsl:if>
<xsl:apply-templates />
</xsl:for-each>
> One possible solution was to create links to the different sections in
> the
> navigation menu but it could get difficult for big documents.
I'm not sure how this would affect performance...
cheers,
v
> Thanks
> Shiva
> --
> View this message in context: http://www.nabble.com/Auto-TOC-for-a-
> document--tf4435727.html#a12654869
> Sent from the Daisy - General mailing list archive at Nabble.com.
>
> _______________________________________________
> daisy community mailing list
> Professional Daisy support:
> http://outerthought.org/site/services/daisy/daisysupport.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
More information about the daisy
mailing list