Skip to content

Added table of contents#82

Open
Chidwan3578 wants to merge 1 commit intoSCDH:masterfrom
Chidwan3578:feature
Open

Added table of contents#82
Chidwan3578 wants to merge 1 commit intoSCDH:masterfrom
Chidwan3578:feature

Conversation

@Chidwan3578
Copy link

I have implemented a Table of Contents (TOC) for the documentation generated by
libodd.xsl. Below is a summary of the changes:

  1. XSLT Enhancements in libodd.xsl
    New Parameter: Added odd:toc (boolean, defaults to true) to toggle the TOC.
    TOC Logic: Created a dedicated odd:toc template and mode that recursively scans for tei:div elements containing a tei:head.
    Anchor Integration: Links in the TOC use the same anchor logic as the main content (targeting the section's xml:id or a generated ID), ensuring seamless navigation.
    Unified Layout: Integrated the TOC into the html:content template so it automatically appears at the top of the generated documentation.

  2. Modern Styling in documentation.css
    Layout: Added a stylized .toc container with a light background and subtle borders to differentiate it from the main content.
    Hierarchy: Styled nested lists to clearly represent the document structure.
    Interactivity: Added hover effects to TOC links for better user experience.

Closes issue #77

@lueck lueck self-requested a review February 26, 2026 15:28
@lueck
Copy link
Member

lueck commented Feb 26, 2026

Your code looks good. However, there's one thing, I'd ask you to change: Though your idea to introduce a stylesheet parameter to toggle the toc on/off is consistent, we should leave it to the processed content, if there's a toc or not. TEI has specified a PI-like element named <divGen>. See https://tei-c.org/release/doc/tei-p5-doc/en/html/DS.html#DSVIRT

So, please remove the stylesheet parameter and its evaluation. Instead, add a template in mode text:text that matches div[@type eq 'toc'] and let it generate a toc in the mode that you introduced.

You may ask yourself, which divisions to process from a <divGen> element. All in //text/body? All the <divGen>'s sibling divisions and their descendants? All the <divGen>'s following sibling devisions and their descendands? Your solution may even depend on the ancestors of the <divGen>: Is it nested in //text/body or in the front matter (//text/front) or back matter (//text/back) of the document? You may take the content model of div-like elements into account. You can even change select="//body" in line 100 of libodd.xsl, if you think that it should be different.

I'm sure, you find a consistent solution.

I've just pushed commit 0650626 for an example is usage of <devGen>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants