Skip to content

Makes all values from #set document(...) available in rheo-context spine structures - #157

Merged
breezykermo merged 6 commits into
mainfrom
feat/full-document-metadata
Jul 21, 2026
Merged

Makes all values from #set document(...) available in rheo-context spine structures#157
breezykermo merged 6 commits into
mainfrom
feat/full-document-metadata

Conversation

@breezykermo

@breezykermo breezykermo commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Adds a DocumentMetadata AST extractor that harvests every representable named argument of the first #set document(...) rule generically into a dict, mirroring DocumentDate's syntax-tree approach rather than string-scanning. keywords round-trips as an array of strings; bracket-content titles flatten to plain text.

Exposes the result as a metadata field on every rheo-context spine and spine-flat entry, alongside handle/path/title.

Adds a DocumentMetadata AST extractor that harvests every representable named
argument of the first #set document(...) rule generically into a dict, mirroring
DocumentDate's syntax-tree approach rather than string-scanning. keywords
round-trips as an array of strings; bracket-content titles flatten to plain text.

Exposes the result as a metadata field on every rheo-context spine and spine-flat
entry, alongside handle/path/title. Extends TypstLiteral with Int/Float so scalar
custom fields round-trip.
Records that #set document(...) metadata is harvested by a pre-compile AST scan
of each vertebra's own source, so template/module-set metadata (applied via a
show rule) is missed even though Typst applies it. Adds docs/limitations.md.
@breezykermo
breezykermo force-pushed the feat/full-document-metadata branch from 77f571f to 5ba6f6a Compare July 21, 2026 10:58
Typst's document element is not extensible: #set document(...) rejects any
argument outside title/author/keywords/date, so Bool/Int/Float MetaValue kinds
were unreachable through a compilable rule. Reduces MetaValue to Str and Array,
reverts the Int/Float additions to TypstLiteral, and corrects the rheo-context
metadata docs to name the reachable fields.
Replaces DocumentTitle::extract() — a raw-text scan that only understood the
bracket title form and mis-parsed a string-form title (grabbing the first
#link[...] body as the title) — with the AST-based DocumentMetadata title.
String and bracket forms both work, smart quotes survive, and the empty/absent
case falls back to the filename. Removes the dead scanner and its tests.

Also gates metadata harvesting to file scope, so a set document(...) inside a
#let helper body (applied elsewhere, not in the defining file) is not mistaken
for this vertebra's own title.
Notes in docs/limitations.md that harvested titles and metadata values are plain
strings: inline formatting markers are stripped and non-textual spans (math,
images, raw) drop entirely, since these feed plain-text sinks (nav, @handle, RSS,
PDF Info).
rheo builds spine titles by flattening #set document(title: …) content to a
plain string. When a bracket title carries styling (_x_, *x*) or sophisticated
content (math, images, raw), that flattening is lossy. The extractor now flags a
lossy title (keeping both the original and stripped forms) and VirtualSpine::build
emits a tracing::warn! naming the file and showing both, so the loss is not silent.
@breezykermo breezykermo changed the title Exposes full #set document(...) metadata on spine entries Makes all values from #set document(...) available in rheo-context spine structures Jul 21, 2026
@breezykermo
breezykermo merged commit 7d4e4d6 into main Jul 21, 2026
11 checks passed
@breezykermo
breezykermo deleted the feat/full-document-metadata branch July 21, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant