On this page:
8.2.1 Term definitions and references
defterm
term
8.2.2 Page References
page-ref
9.1

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🔗

procedure

(defterm content ...)  list?

  content : any/c
Defines a term in a Punct document. The content is displayed as-is and also used to derive the normalized key for cross-references. Produces a term-definition x-expression rendered as a <dfn> element with an id anchor.

The anchor key/id is derived from a normalization of the content:

  1. Case-folded to lowercase

  2. Trailing ies converted to y (e.g., “libraries” matches “library”)

  3. Trailing sses converted to ss (e.g., “classes” matches “class”)

  4. Trailing s removed, except within ss (e.g., “names” matches “name”)

  5. Whitespace collapsed and replaced with hyphens

procedure

(term content ...)  list?

  content : any/c
Produces an element for content and hyperlinks it to the defterm definition site of the term. The lookup key is derived from content using the same normalization process used by defterm.

8.2.2 Page References🔗

procedure

(page-ref slug content ...)  list?

  slug : string?
  content : any/c
Produces a hyperlink to another page using its slug. Slugs are normalized for consistent cross-reference resolution:

  • 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—for example, pages in different collections with the same filename, or a page whose slug meta overrides to match another page’s slug—the later page (in collection order) silently shadows the earlier one in the page index. A warning is logged during the collect phase when this occurs, but the build is not halted.