Makes all values from #set document(...) available in rheo-context spine structures - #157
Merged
Merged
Conversation
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
force-pushed
the
feat/full-document-metadata
branch
from
July 21, 2026 10:58
77f571f to
5ba6f6a
Compare
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.
#set document(...) available in rheo-context spine structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-contextspine and spine-flat entry, alongside handle/path/title.