(sigil publish transform)
(sigil publish transform) - Content Transforms
Transforms are functions that modify SXML nodes. The pipeline handles tree traversal - transform authors write single-node functions: (node context) -> node
Built-in transforms:
- add-heading-anchors: Adds id attributes to headings
- syntax-highlight: Highlights Scheme/Sigil code blocks
Exports
apply-transformsprocedureApply a list of transforms to a document.
Walks the SXML tree in document children, applying each transform function to every node. Transforms receive (node context) and return a possibly-modified node.
add-heading-anchorsprocedureAdd id attributes to heading elements (h1-h6).
Creates a URL-friendly slug from the heading text content and adds it as the id attribute for deep linking.
syntax-highlightprocedureHighlight Scheme/Sigil code blocks.
Handles two formats:
- (pre (@ (lang "scheme")) ...) from markdown
- (pre (code (@ (class "language-scheme")) ...)) standard HTML
Tokenizes the code and wraps tokens in spans with CSS classes like tok-comment, tok-string, tok-keyword, etc.
Transform signature: (config state item node) -> node
resolve-refsprocedureResolve special reference links in content.
Transforms Markdown-style links with special URL schemes:
If link text is empty, auto-fills from the reference title.
Examples:
[First Post](ref:blog:first-post) -> link to blog post
[](ref:blog:first-post) -> auto-titled link
[assoc-ref](api:sigil/core#assoc-ref) -> API doc linkslugifyprocedureConvert text to a URL-friendly slug.