feat(glossy): Check validity of modifiers
When an unrecognized modifier is applied, glossy should panic to warn the user, instead of silently ignoring the modifier. This might catch potential misspellings of modifiers.
This commit is contained in:
1 parent
a6572d07ff
commit
ae6405c288
2 files changed
+8
-5
No files matched your search
@@ -411,3 +411,5 @@ This project is licensed under the MIT License.
|
||||
now counts towards the first use of a term.
|
||||
- **Breaking**: When multiple conflicting modes are supplied (like 'short'
|
||||
and 'long'), glossy now throws an error (with a clear message).
|
||||
- **Breaking**: When an unrecognized modifier is supplied with the term,
|
||||
glossy will now panic instead of ignoring the modifier.
|
||||
@@ -227,7 +227,7 @@
|
||||
#let __gls(key, modes-modifiers: array, format-term: function, show-term: function, term-links: true, display-text: none) = {
|
||||
let possible_modes = ("auto", "both", "short", "long", "description", "supplement")
|
||||
// ---------------------------------------------------------------------------
|
||||
// Normalize mode & modifier inputs AND first sanitization
|
||||
// Normalize mode & modifier inputs AND check if the modifiers are valid
|
||||
// ---------------------------------------------------------------------------
|
||||
let modes-modifiers = modes-modifiers.map(it => {
|
||||
if it == "def" or it == "desc" {
|
||||
@@ -240,11 +240,12 @@
|
||||
return "no-use"
|
||||
} else if it == "noref" or it == "noindex" {
|
||||
return "noindex"
|
||||
} else if it in ("auto", "supplement", "__MIDDLE_ITEM") {
|
||||
// Already internally used, don't make user input confuse us
|
||||
panic(it, "should not be used as a modifier")
|
||||
} else {
|
||||
} else if it in ("both", "short", "long", "cap", "pl",) {
|
||||
return it
|
||||
} else if it in ("auto", "description", "supplement") {
|
||||
panic(it, "is a valid mode, but is not used by applying a modifier with this name. Read the documentation.")
|
||||
} else {
|
||||
panic(it, "is not a recognized mode or modifier.")
|
||||
}
|
||||
})
|
||||
if display-text != none and display-text != auto {
|
||||
|
||||
Reference in new issue
Block a user