diff --git a/glossy/README.md b/glossy/README.md index ec7164c..5a04649 100644 --- a/glossy/README.md +++ b/glossy/README.md @@ -85,6 +85,10 @@ Each glossary entry supports the following fields: - `plural` (optional): Override automatic pluralization of short form - `longplural` (optional): Override automatic pluralization of long form +Note that if you just want an entry with `short` and `long`, you can use the +abbreviated syntax. In this case, they `key` is used as the short form, and its +value is used as the long form. See `WWW` as an example below. + You can also load glossary entries from a data file using #yaml(), #json(), or similar. For example, the above glossary could be in this YAML file: diff --git a/glossy/src/gloss.typ b/glossy/src/gloss.typ index a919350..3956ff3 100644 --- a/glossy/src/gloss.typ +++ b/glossy/src/gloss.typ @@ -10,21 +10,28 @@ // with appropriate default values. // // Parameters: +// key: The key from the input dictionary // entry (dictionary): Input dictionary containing at least 'short' and optionally // 'long', 'plural', 'longplural', 'description', and 'group' // +// entry (string): If you pass a string to entry, we assume you're using the +// abbreviated syntax `short: "long"`, where the `key` is used +// for `short` and `entry` is used for `long`. +// // Returns: // dictionary: Normalized dictionary with all expected keys populated // // Throws: -// - If 'short' key is missing +// - If 'short' key is missing when using normal (non-abbreviated) syntax // - If 'short' value is not a string // - If 'short' value is an empty string // #let __normalize_entry(key, entry) = { - if (type(entry) == str){ + // If it's a string, it's using the abbreviated syntax `short: "long"`. + if (type(entry) == str) { entry = (short: key, long: entry) } + // Validate required fields if not "short" in entry { panic("Entry must contain a 'short' key")