Skip to content

Commit

Permalink
Merge pull request #75 from typst-community/66-possibility-to-print-o…
Browse files Browse the repository at this point in the history
…nly-certain-groups-with-print-glossary

Add groups parameter to filter displayed groups
  • Loading branch information
quachpas authored Oct 27, 2024
2 parents d407ff0 + 8d78125 commit 4f67cec
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 4f67cec

Please sign in to comment.