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:
1 parent
392e8a8122
commit
68945132fb
3 files changed
+19
-32
No files matched your search
+7
-3
@@ -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
|
||||
|
||||
|
||||
+10
-27
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user