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 groups parameter to filter displayed groups #75

Merged
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
16 changes: 15 additions & 1 deletion themes/default.typ
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@

// print-glossary(
// entry-list,
// groups: (),
// show-all: false,
// disable-back-references: false,
// group-heading-level: none,
Expand All @@ -866,6 +867,7 @@
//
// # Arguments
// entry-list (list<dictionary>): the list of entries
// groups (array<str>): the list of groups to be displayed. `""` is the default group.
// show-all (bool): show all entries
// disable-back-references (bool): disable back references
// ...
Expand All @@ -882,6 +884,7 @@
// ```
#let print-glossary(
entry-list,
groups: (),
show-all: false,
disable-back-references: false,
group-heading-level: none,
Expand All @@ -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
Expand All @@ -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,
Expand Down
Loading