feat(glossy): Remove hide/hidden modifier

This modifier was not orthogonal with other modifiers (for example, it
could not be used together with :noindex)
Added documentation and modified test to reflect that @term[] with an
empty supplement has exactly the same result *and* is more orthogonal.

This partially reverts commit 5957432d5d.
This commit is contained in:
swaits authored and swaits committed 2025-10-26 16:00:21 -06:00
1 parent 392e8a8122
commit 68945132fb
3 files changed
+19 -32

No files matched your search

+7 -3
View File
@@ -198,9 +198,13 @@ which would normally render as something like "test procedure specification."
But for some reason you want it to actually say "an annoying report." You can do But for some reason you want it to actually say "an annoying report." You can do
that like this: that like this:
| **Input** | **Output** | | **Input** | **Output** |
| ------------------------- | -------------------- | | -------------------------- | -------------------- |
| `@tps[an annoying report` | "an annoying report" | | `@tps[an annoying report]` | "an annoying report" |
| `@tps[]` | #none |
In case you want to reference a term from the Glossary/Index, but don't
want to display it for whatever reason, the second form can be used.
### First use logic ### First use logic
+10 -27
View File
@@ -207,8 +207,6 @@
// - "long": Show only the long form. // - "long": Show only the long form.
// - "def" or "desc": Show the term's description instead of its name. // - "def" or "desc": Show the term's description instead of its name.
// - "a" or "an": Prepend an article, chosen from the entry (short or long form). // - "a" or "an": Prepend an article, chosen from the entry (short or long form).
// - "hide" or "hidden": Use term (for the sake of the glossary/index),
// but don't display it.
// show-term (function): A function that renders the chosen term. // show-term (function): A function that renders the chosen term.
// term-links (boolean): If terms should be clickable links leading to glossary // term-links (boolean): If terms should be clickable links leading to glossary
// //
@@ -233,9 +231,6 @@
if ("a" in modifiers or "an" in modifiers) and ("pl" in modifiers) { if ("a" in modifiers or "an" in modifiers) and ("pl" in modifiers) {
panic("Cannot use 'a'/'an' and 'pl' together.") panic("Cannot use 'a'/'an' and 'pl' together.")
} }
if ("hidden" in modifiers or "hide" in modifiers) and modifiers.len() > 1{
panic("Cannot use 'hide'/'hidden' with other modifiers.")
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Retrieve the glossary entry and its label // Retrieve the glossary entry and its label
@@ -315,11 +310,8 @@
// If no explicit mode is given, the default behavior is: // If no explicit mode is given, the default behavior is:
// - On first use and if a long form exists, "both". // - On first use and if a long form exists, "both".
// - Otherwise, "short". // - Otherwise, "short".
let determine_mode = (wants_both, wants_long, wants_short, is_first_use, long_available, wants_hidden) => { let determine_mode = (wants_both, wants_long, wants_short, is_first_use, long_available) => {
if wants_hidden { if wants_both {
// If it's hidden, nothing else matters
"hidden"
} else if wants_both {
// Explicit request for "both": // Explicit request for "both":
// If a long form exists, use "both", otherwise fall back to "short". // If a long form exists, use "both", otherwise fall back to "short".
if long_available { if long_available {
@@ -357,11 +349,10 @@
let wants_both = "both" in modifiers let wants_both = "both" in modifiers
let wants_long = "long" in modifiers let wants_long = "long" in modifiers
let wants_short = "short" in modifiers let wants_short = "short" in modifiers
let wants_hidden = ("hidden" in modifiers or "hide" in modifiers)
let long_available = entry.long != none let long_available = entry.long != none
// Determine mode using the helper function // Determine mode using the helper function
let mode = determine_mode(wants_both, wants_long, wants_short, is_first_use, long_available, wants_hidden) let mode = determine_mode(wants_both, wants_long, wants_short, is_first_use, long_available)
// Pluralize (if requested) // Pluralize (if requested)
let short-form = pluralize_term(entry.short, entry.plural) let short-form = pluralize_term(entry.short, entry.plural)
@@ -403,21 +394,13 @@
} }
// Create the output content // Create the output content
if mode == "hidden" { [#article#show-term(linked-term)#metadata(term)#term-label]
// just put the metadata+label out there // |^^^^^|^^^^^^^^^ |^^^^^^^^ |^^^^^^^^^^
[#metadata("hidden term")#term-label] // | | | \_ the label for backlink from
} else { // | | | glossary i.e. <__gloss:key>, etc.
// normal term display (ie not hidden) // | | \_ metadata lets us label (ie makes it "labelable")
[#article#show-term(linked-term)#metadata(term)#term-label] // | \_ apply user formatting function to the term
// |^^^^^|^^^^^^^^^ |^^^^^^^^ |^^^^^^^^^^^^ // \_art.
// \_art.| | |
// \_ apply user formatting function to the term
// | |
// \_ metadata lets us label (ie makes it "labelable")
// |
// \_ i.e. <__gloss:key>, etc.
// for backlink from glossary
}
} }
} }
+2 -2
View File
@@ -24,9 +24,9 @@
= Hiding terms = Hiding terms
Here's a hidden term: @html:hide Here's a hidden term: @html[]
Here's another hidden term: @css:hidden Here's another hidden term: @css[]
And here's a shown term: @tps And here's a shown term: @tps