Re: PATCH: Autogenerate table of contents for docs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 30, 2008 at 02:05:12PM +0100, Daniel P. Berrange wrote:
> Alot of the docs pages have manually written table of contents linking to
> headings with the page. I figured this is a good candidate for being
> auto-generated.
> 
> The basic idea is that given a document with  a series of headings
> 
>    <h2><a name="xxx">Foo</a></h2>
>    ..
>    <h3><a name="xxx">Bar</a></h3>
>    ..
>    <h3><a name="xxx">Wizz</a></h3>
>    ..
>    <h2><a name="xxx">Oooh</a></h2>
>    ..
>    <h3><a name="xxx">Ahhh</a></h3>
> 
> Then, generate a table of contents with a nested set of lists <ul>. THe
> XSL below attempts todo this for heading levels h2 -> h6, and splices the
> TOC into the page where it sees an <ul id='toc'></ul> element (typically
> just after <h1>).
> 
> I'm kind of out of practice with XSL, so there's probably a nicer way
> to write the 'toc' template below...

  Yeah, it look weird but since:
   1/ the HTML is flat you can't base counting more on structure
   2/ h2/h3/h4/h5/h6 are not a real subsetting pattern you can't
      use recursion 

 one suggestion, instead of
   <a href="#{a/@name}"><xsl:value-of select="a/text()"/></a>
at each level, use something like
   <a href="#{a/@name}"><xsl:text><xsl:value-of select="string(a)"/></xsl:text></a>
to still capture text if the header is not just made of a single text node.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]