8.2 Cross-Reference System
| (require camp/xref) | package: camp-lib |
The camp/xref module provides functions for defining terms and creating cross-references within Punct source documents. The term system works like Scribble’s deftech/tech: terms are normalized for lookup, allowing references to match definitions even with differences in pluralization or capitalization.
8.2.1 Term definitions and references
The anchor key/id is derived from a normalization of the content:
Case-folded to lowercase
Trailing ies converted to y (e.g., “libraries” matches “library”)
Trailing sses converted to ss (e.g., “classes” matches “class”)
Trailing s removed, except within ss (e.g., “names” matches “name”)
Whitespace collapsed and replaced with hyphens
8.2.2 Page References
Case-folded to lowercase
Non-alphanumeric characters replaced with hyphens
Multiple hyphens collapsed to single hyphen
Leading/trailing hyphens removed
This allows natural references like •page-ref{My Page} to resolve to a page with slug "my-page".
If no content is provided, it is used as the link text; otherwise the page’s title is used as the link text.
Slugs should be unique across the entire site. If two pages share the same normalized slug—