Skip to content

Commit

Permalink
Add minimum-refs parameter to filter terms displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
quachpas committed Oct 27, 2024
1 parent ab802e0 commit b8b6d12
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions themes/default.typ
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@
// entry,
// show-all: false,
// disable-back-references: false,
// minimum-refs: 1,
// user-print-title: default-print-title,
// user-print-description: default-print-description,
// user-print-back-references: default-print-back-references,
Expand All @@ -636,6 +637,7 @@
// entry (dictionary): the entry
// show-all (bool): show all entries
// disable-back-references (bool): disable back references
// minimum-refs (int): minimum number of references to show the entry
// ...
//
// # Returns
Expand All @@ -644,14 +646,15 @@
entry,
show-all: false,
disable-back-references: false,
minimum-refs: 1,
user-print-title: default-print-title,
user-print-description: default-print-description,
user-print-back-references: default-print-back-references,
) = (
context {
let caption = []

if show-all == true or count-refs(entry) != 0 {
if show-all == true or count-refs(entry) >= minimum-refs {
// Title
caption += user-print-title(entry)

Expand All @@ -677,6 +680,7 @@
// entry,
// show-all: false,
// disable-back-references: false,
// minimum-refs: 1,
// user-print-gloss: default-print-gloss,
// user-print-title: default-print-title,
// user-print-description: default-print-description,
Expand All @@ -688,6 +692,7 @@
// entry (dictionary): the entry
// show-all (bool): show all entries
// disable-back-references (bool): disable back references
// minimum-refs (int): minimum number of references to show the entry
// ..;
//
// # Returns
Expand All @@ -696,6 +701,7 @@
entry,
show-all: false,
disable-back-references: false,
minimum-refs: 1,
user-print-gloss: default-print-gloss,
user-print-title: default-print-title,
user-print-description: default-print-description,
Expand All @@ -714,6 +720,7 @@
entry,
show-all: show-all,
disable-back-references: disable-back-references,
minimum-refs: minimum-refs,
user-print-title: user-print-title,
user-print-description: user-print-description,
user-print-back-references: user-print-back-references,
Expand Down Expand Up @@ -742,6 +749,7 @@
// show-all: false,
// disable-back-references: false,
// group-heading-level: none,
// minimum-refs: 1,
// user-print-reference: default-print-reference
// user-group-break: default-group-break,
// user-print-gloss: default-print-gloss,
Expand All @@ -757,6 +765,7 @@
// show-all (bool): show all entries
// disable-back-references (bool): disable back references
// group-heading-level (int): force the level of the group heading
// minimum-refs (int): minimum number of references to show the entry
// ...
//
// # Warnings
Expand All @@ -772,6 +781,7 @@
show-all: false,
disable-back-references: false,
group-heading-level: none,
minimum-refs: 1,
user-print-reference: default-print-reference,
user-group-break: default-group-break,
user-print-gloss: default-print-gloss,
Expand All @@ -792,7 +802,7 @@
let group-entries = entries.filter(x => x.at("group") == group)
let group-ref-counts = group-entries.map(count-refs)

let print-group = (group != "" and (show-all == true or group-ref-counts.any(x => x > 0)))
let print-group = (group != "" and (show-all == true or group-ref-counts.any(x => x >= minimum-refs)))

// Only print group name if any entries are referenced
if print-group {
Expand All @@ -804,6 +814,7 @@
entry,
show-all: show-all,
disable-back-references: disable-back-references,
minimum-refs: minimum-refs,
user-print-gloss: user-print-gloss,
user-print-title: user-print-title,
user-print-description: user-print-description,
Expand Down Expand Up @@ -855,6 +866,7 @@
// show-all: false,
// disable-back-references: false,
// group-heading-level: none,
// minimum-refs: 1,
// user-print-glossary: default-print-glossary,
// user-print-reference: default-print-reference,
// user-group-break: default-group-break,
Expand All @@ -871,6 +883,7 @@
// show-all (bool): show all entries
// disable-back-references (bool): disable back references
// group-heading-level (int): force the level of the group heading
// minimum-refs (int): minimum number of references to show the entry
// ...
//
// # Warnings
Expand All @@ -889,6 +902,7 @@
show-all: false,
disable-back-references: false,
group-heading-level: none,
minimum-refs: 1,
user-print-glossary: default-print-glossary,
user-print-reference: default-print-reference,
user-group-break: default-group-break,
Expand Down Expand Up @@ -940,6 +954,7 @@
show-all: show-all,
disable-back-references: disable-back-references,
group-heading-level: group-heading-level,
minimum-refs: minimum-refs,
user-print-reference: user-print-reference,
user-group-break: user-group-break,
user-print-gloss: user-print-gloss,
Expand Down

0 comments on commit b8b6d12

Please sign in to comment.