Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option use-key-as-short for register-glossary #87

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/debug/debug.typ
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,11 @@ false: #context there-are-refs(groups: (" ",))

#default-print-reference.with(show-all: true)(entry-list-2.last())

== Test use-key-as-short

#let entry-list-6 = ((key: "potato-use-key-as-short"),)
#register-glossary(entry-list-6)
#print-glossary(entry-list-6)
@potato-use-key-as-short

]
16 changes: 9 additions & 7 deletions themes/default.typ
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,19 @@
//
// # Arguments
// entry-list (array<dictionary>): the list of entries
// use-key-as-short (bool): flag to use the key as the short form
//
// # Returns
// The normalized entry list
#let __normalize_entry_list(entry-list) = {
#let __normalize_entry_list(entry-list, use-key-as-short: true) = {
let new-list = ()
for entry in entry-list {
if not has-short(entry) and not has-long(entry) {
if not use-key-as-short and not has-short(entry) and not has-long(entry) {
panic(__error_message(entry.key, __entry_has_neither_short_nor_long))
}
new-list.push((
key: entry.key,
short: entry.at("short", default: ""),
short: entry.at("short", default: if use-key-as-short { entry.key } else { "" }),
artshort: entry.at("artshort", default: "a"),
plural: entry.at("plural", default: ""),
long: entry.at("long", default: ""),
Expand Down Expand Up @@ -914,17 +915,18 @@
})
}

// register-glossary(entry-list) -> none
// register-glossary(entry-list, use-key-as-short: true) -> none
// Register the glossary entries
//
// # Arguments
// entries (array<dictionary>): the list of entries
#let register-glossary(entry-list) = {
// entries (array<dictionary>): the list of entries
// use-key-as-short (bool): flag to use the key as the short form
#let register-glossary(entry-list, use-key-as-short: true) = {
if sys.version <= version(0, 11, 1) {
return
}
// Normalize entry-list
let entries = __normalize_entry_list(entry-list)
let entries = __normalize_entry_list(entry-list, use-key-as-short: use-key-as-short)

__update_glossary(entries)
}
Expand Down
Loading