SEP 42: Expose Abstract Syntax Tree (AST)

This should await resolution of SEP 13: Switch to a more reasonable source markup language as the transition to Djot or another parser would be an ideal time to create stronger semantic ties to the document tree.

SEP 13 has since been completed. Though I am considering writing my own parser from scratch to obviate the current parser/substitution split.

Currently, several features that I might like to implement that tie in to document structure are blocked by the fact that during the site build the AST (Abstract Syntax Tree) of the parsed source documents is not exposed.

The chief examples at the moment have to do with my plans for creating, manipulating, and referencing ‘Table(s) of Content’ for documents. Having composable control, on a document by document basis, over which elements are represented in a TOC, how they’re nested, and where it is presented is something I’m dead keen on.

My ambition for this extends also to transclusion (see SEP 17: Document Transclusion): I want to be able to dynamically include all or part of the TOC of one document within the body of another document for ever richer interlinking.

Exposing the AST within the build would also offer interesting opportunities for document/syntax aware visualisations (see SEP 40: Graphs and maps: contextualising with visualisations).