From 68945132fbf9377a0e83b4df6bef891f0a4cab00 Mon Sep 17 00:00:00 2001 From: Thijs Paelman Date: Fri, 23 May 2025 21:17:25 +0200 Subject: [PATCH] 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 5957432d5d76bfd64c3a1ab4ec0987628c5f9fa5. --- glossy/README.md | 10 +++++--- glossy/src/gloss.typ | 37 ++++++++---------------------- glossy/tests/hidden-terms/test.typ | 4 ++-- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/glossy/README.md b/glossy/README.md index 2c04c5c..4c798aa 100644 --- a/glossy/README.md +++ b/glossy/README.md @@ -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 that like this: -| **Input** | **Output** | -| ------------------------- | -------------------- | -| `@tps[an annoying report` | "an annoying report" | +| **Input** | **Output** | +| -------------------------- | -------------------- | +| `@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 diff --git a/glossy/src/gloss.typ b/glossy/src/gloss.typ index d10bfaf..ccc7781 100644 --- a/glossy/src/gloss.typ +++ b/glossy/src/gloss.typ @@ -207,8 +207,6 @@ // - "long": Show only the long form. // - "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). -// - "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. // 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) { 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 @@ -315,11 +310,8 @@ // If no explicit mode is given, the default behavior is: // - On first use and if a long form exists, "both". // - Otherwise, "short". - let determine_mode = (wants_both, wants_long, wants_short, is_first_use, long_available, wants_hidden) => { - if wants_hidden { - // If it's hidden, nothing else matters - "hidden" - } else if wants_both { + let determine_mode = (wants_both, wants_long, wants_short, is_first_use, long_available) => { + if wants_both { // Explicit request for "both": // If a long form exists, use "both", otherwise fall back to "short". if long_available { @@ -357,11 +349,10 @@ let wants_both = "both" in modifiers let wants_long = "long" in modifiers let wants_short = "short" in modifiers - let wants_hidden = ("hidden" in modifiers or "hide" in modifiers) let long_available = entry.long != none // 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) let short-form = pluralize_term(entry.short, entry.plural) @@ -403,21 +394,13 @@ } // Create the output content - if mode == "hidden" { - // just put the metadata+label out there - [#metadata("hidden term")#term-label] - } else { - // normal term display (ie not hidden) - [#article#show-term(linked-term)#metadata(term)#term-label] - // |^^^^^|^^^^^^^^^ |^^^^^^^^ |^^^^^^^^^^^^ - // \_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 - } + [#article#show-term(linked-term)#metadata(term)#term-label] + // |^^^^^|^^^^^^^^^ |^^^^^^^^ |^^^^^^^^^^ + // | | | \_ the label for backlink from + // | | | glossary i.e. <__gloss:key>, etc. + // | | \_ metadata lets us label (ie makes it "labelable") + // | \_ apply user formatting function to the term + // \_art. } } diff --git a/glossy/tests/hidden-terms/test.typ b/glossy/tests/hidden-terms/test.typ index ffbaf3a..49a4542 100644 --- a/glossy/tests/hidden-terms/test.typ +++ b/glossy/tests/hidden-terms/test.typ @@ -24,9 +24,9 @@ = 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