fix(glossy): Ensure ∅ supplement results in ∅ content

Ensure an empty supplement results in glossy returning empty content,
instead of an empty string. Done by returning #none if no article is
wanted.

When the value #none is returned for the article, this can neatly join
with the other values without a trace. In particular, when `term` is
empty content, this ensures that only #metadata remains, exactly like
in the 'hidden' case.

Effectively, now @term[] is identical to @term:hidden, because no empty
string is inserted. This can be seen in the updated test case, where the
spaces around the blank term are now collapsed to a single space by
Typst, instead of keeping two spaces like before.

A next commit will remove :hidden, since it's not orthogonal w.r.t.
other modifiers, while using a supplement is.
This commit is contained in:
swaits authored and swaits committed 2025-10-26 16:00:21 -06:00
1 parent 3e0d7a9812
commit 392e8a8122
2 files changed
+3 -3

No files matched your search

+3 -3
View File
@@ -282,7 +282,7 @@
let capitalize_term = (article, term) => { let capitalize_term = (article, term) => {
if "cap" not in modifiers { if "cap" not in modifiers {
(article, term) (article, term)
} else if article == "" { } else if article == none {
// No article present, so capitalize the term's first letter. // No article present, so capitalize the term's first letter.
(article, upper(term.first()) + term.slice(1)) (article, upper(term.first()) + term.slice(1))
} else { } else {
@@ -292,14 +292,14 @@
} }
// get_article(mode): Returns the appropriate article string based on the mode. // get_article(mode): Returns the appropriate article string based on the mode.
// - If wants_article is false, returns an empty string. // - If wants_article is false, returns none
// - If mode is "short", return the short article. // - If mode is "short", return the short article.
// - If mode is "long" or "both", return the long article. // - If mode is "long" or "both", return the long article.
// The calling logic ensures that when mode = "long" or "both", a long form exists. // The calling logic ensures that when mode = "long" or "both", a long form exists.
let get_article = (mode) => { let get_article = (mode) => {
let wants_article = "a" in modifiers or "an" in modifiers let wants_article = "a" in modifiers or "an" in modifiers
if not wants_article { if not wants_article {
"" none
} else if mode == "short" { } else if mode == "short" {
entry.article + " " entry.article + " "
} else { } else {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 27 KiB