From 8d78125f863ba6292972139e2edd67b5a61350f8 Mon Sep 17 00:00:00 2001 From: Pascal Quach Date: Sun, 27 Oct 2024 10:53:53 +0100 Subject: [PATCH] Add groups parameter to filter displayed groups --- themes/default.typ | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/themes/default.typ b/themes/default.typ index 521e000..c6010a6 100644 --- a/themes/default.typ +++ b/themes/default.typ @@ -851,6 +851,7 @@ // print-glossary( // entry-list, +// groups: (), // show-all: false, // disable-back-references: false, // group-heading-level: none, @@ -866,6 +867,7 @@ // // # Arguments // entry-list (list): the list of entries +// groups (array): the list of groups to be displayed. `""` is the default group. // show-all (bool): show all entries // disable-back-references (bool): disable back references // ... @@ -882,6 +884,7 @@ // ``` #let print-glossary( entry-list, + groups: (), show-all: false, disable-back-references: false, group-heading-level: none, @@ -896,6 +899,9 @@ if entry-list == none { panic("entry-list is required") } + if type(groups) != array { + panic("groups must be an array") + } let entries = () if sys.version <= version(0, 11, 1) { // Normalize entry-list @@ -914,14 +920,22 @@ // Glossary let body = [] body += context { + // Entries let el = if sys.version <= version(0, 11, 1) { entries } else if entry-list != none { __glossary_entries.get().values().filter(x => (x.key in entry-list.map(x => x.key))) } + + // Groups + let g = if groups == () { + el.map(x => x.at("group")).dedup() + } else { + groups + } user-print-glossary( el, - el.map(x => x.at("group")).dedup(), + g, show-all: show-all, disable-back-references: disable-back-references, group-heading-level: group-heading-level,