From 91de1816e905049d859924b3bd3e2c71367b4d34 Mon Sep 17 00:00:00 2001 From: Philipp Niedermayer Date: Sun, 15 Dec 2024 19:32:27 +0000 Subject: [PATCH] Allow concise entry definition closes #13 --- glossy/README.md | 5 ++++- glossy/src/gloss.typ | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/glossy/README.md b/glossy/README.md index 41b5e86..ec7164c 100644 --- a/glossy/README.md +++ b/glossy/README.md @@ -69,7 +69,8 @@ Use the `init-glossary` function to initialize glossary entries: // Optional: Override automatic pluralization plural: "TPSes", longplural: "test procedure specifications" - ) + ), + WWW: "World Wide Web", // concise entry with only short: long ) #show: init-glossary.with(myGlossary) @@ -107,6 +108,8 @@ tps: description: A formal document describing test steps and expected results plural: TPSes longplural: test procedure specifications + +WWW: World Wide Web ``` And then loaded during initialization as follows: diff --git a/glossy/src/gloss.typ b/glossy/src/gloss.typ index 3fd2e15..a919350 100644 --- a/glossy/src/gloss.typ +++ b/glossy/src/gloss.typ @@ -21,7 +21,10 @@ // - If 'short' value is not a string // - If 'short' value is an empty string // -#let __normalize_entry(entry) = { +#let __normalize_entry(key, entry) = { + if (type(entry) == str){ + entry = (short: key, long: entry) + } // Validate required fields if not "short" in entry { panic("Entry must contain a 'short' key") @@ -329,7 +332,7 @@ // Process and store each glossary entry for (key, entry) in entries { - __add_entry(key, __normalize_entry(entry)) + __add_entry(key, __normalize_entry(key, entry)) } // Set up reference handling for glossary terms