Skip to content

refactor: let the schema decide an option's default - #68

Merged
mcanouil merged 4 commits into
mainfrom
refactor/option-defaults-schema
Sep 21, 2026
Merged

mcanouil merged 4 commits into
mainfrom
refactor/option-defaults-schema

Conversation

@mcanouil

Copy link
Copy Markdown
Owner

_schema.yml declares a default for each of the seven options, and a table in the Lua declared the same seven again. The schema check already answers what the schema says, and that answer was thrown away, so the literals decided while the schema was what the editor showed. Changing a default in _schema.yml alone did nothing, and nothing reported the difference.

The check's answer is kept now, and the table is demoted to a fallback for the two cases the schema cannot answer: a format the extension does not act on, where the check never runs, and a schema that could not be read, which is a state the extension renders through rather than stopping for.

The schema is read first and the fallback fills only what it leaves unanswered. The other order would have made the fallback the list of options allowed to have a default at all, which is the coupling this removes.

Three checks cover it. The wrapper name comes from the schema, it follows a change made in the schema alone, and it falls back when the file is gone. The wrapper is the option under test because it reaches the Typst output word for word, and the middle check also requires the old name to be absent, so a rename that missed a call site fails.

The three hot-fix defaults are still kept by hand. They are nested in the schema and read on their own path, which takes a boolean or a map, so they need more than a table of defaults handed to the options reader. That is tracked separately, and the comment in the code says so rather than claiming the schema decides everything.

No behaviour changes, so there is no changelog entry. Nineteen tests pass, example.qmd renders byte-identical to main in HTML, Typst and Reveal.js, and the documentation site renders with no warnings. Three review rounds.

@mcanouil mcanouil self-assigned this Sep 21, 2026
@mcanouil mcanouil added the Type: Refactor 🔥 Issues related to refactoring, restructuring, or cleaning up label Sep 21, 2026
@mcanouil
mcanouil marked this pull request as ready for review September 21, 2026 09:52
The schema declares a default for each of the seven options, and a table
in the Lua declared the same seven again. The check already answers what
the schema says, and that answer was dropped, so the literals decided
while the schema was what the editor showed. Changing a default in
_schema.yml alone did nothing.

The check's answer is kept now. The table stays as a fallback for the
two cases the schema cannot answer: a format the extension does not act
on, where the check never runs, and a schema that could not be read,
which is a state the extension renders through.

Three fixtures cover it: the wrapper name comes from the schema, follows
a change made there alone, and falls back when the file is gone.

The three hotfix defaults are still declared twice. They are nested in
the schema and read through a different path, so they are left alone
here.
@mcanouil
mcanouil force-pushed the refactor/option-defaults-schema branch from 974f006 to 698505c Compare September 21, 2026 10:58
@mcanouil
mcanouil merged commit 9203398 into main Sep 21, 2026
2 checks passed
@mcanouil
mcanouil deleted the refactor/option-defaults-schema branch September 21, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Refactor 🔥 Issues related to refactoring, restructuring, or cleaning up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant