Description
Motivation
Currently, when selecting a variant from a set of modifiers, the first variant from the list that contains all the modifiers, and a minimal amount of additional modifiers, is chosen.12 This means using non-fully qualified names when referring to a symbol might cause breakage when Codex is updated. For example, consider the following symbol:
arrow
.l ←
.r →
.r.bar ↦
arrow.bar
resolves to arrow.r.bar
, which is ↦. Now, suppose a new version of Codex changes the symbol to the following:
arrow
.l ←
.l.bar ↤
.r →
.r.bar ↦
Now, arrow.bar
will resolve to arrow.l.bar
, which is ↤.
Essentially, this means adding new variants in the middle of the variant list can cause unexpected breakage. As of now, there is no policy regarding what constitute a breaking change when it comes to fallbacks.
Proposed solution
The intuitive idea of this solution is to make explicit what parts of the fully qualified form (i.e., which modifiers) can be omitted.
As before, each variant has a set of modifiers. Hereafter, we refer to this set of modifiers as the fully qualified form, denoted
The current behavior corresponds to having
This improves forward-compatibility by explicitly specifying which fallbacks can be relied on, and which can't. Ideally, there could even be an automated way of detecting breakages. This is currently not feasible, because most breakages are not implicitly guaranteed to be future proof.3
Other benefits
As well as improving forward compatibility, this proposal can be the source of documentation improvements. Indeed, the current documentation45 only presents fully qualified names. For some common symbols, this can be problematic. For example, sym.errorbar.square.stroked
can be accessed through simply sym.errorbar
, but the documentation does not reflect that. With this proposal, the documentation can present
As mentioned previously, this proposal would make it possible to detect breakages automatically, because it clarifies which non-fully qualified variants are legal and clearly defined, and which are not.
Footnotes
-
This is actually not defined in Codex, but in Typst. Making the variant selection part of Codex is the topic of Resolve modifiers #30. ↩
-
https://github.com/typst/typst/blob/d199546f9fe92b2d380dc337298fdca3e6fca8c8/crates/typst-library/src/foundations/symbol.rs#L387-L420 ↩
-
For example,
sym.angle.top
currently resolves tosym.angle.spheric.top
(⦡), but this is more a side effect of the fact that there is no baresym.angle.top
symbol than a conscious decision, and shouldn't be relied upon. ↩