Skip to content

Commit

Permalink
Merge pull request #79 from typst-community/docs-groups-count-refs
Browse files Browse the repository at this point in the history
Add examples and tests for new group features and count-refs
  • Loading branch information
quachpas authored Oct 27, 2024
2 parents a1fce98 + c54c6b7 commit f350eb5
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
67 changes: 66 additions & 1 deletion examples/groups/groups.typ
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
long: "Default2",
description: lorem(25),
group: "", // Please note that an empty group has the same effect as no group
),
),
)
#register-glossary(entry-list)

Expand All @@ -52,3 +52,68 @@ Reference to @bor
entry-list,
show-all: true,
)

= Glossary with custom group heading level

#let entry-list-2 = (
(
key: "A",
short: "A",
group: "Group A",
),
(
key: "B",
short: "B",
group: "Group B",
),
)
#register-glossary(entry-list-2)

Reference to @A
Reference to @B

#print-glossary(
entry-list-2,
show-all: true,
group-heading-level: 3,
)

= Glossary with custom group display

#let entry-list-3 = (
(
key: "C",
short: "C",
group: "Group C",
),
(
key: "D",
short: "D",
group: "Group D",
),
(
key: "E",
short: "E",
),
)
#register-glossary(entry-list-3)

// Reference to @C // Error: Reference to @C not found
// Reference to @D // Error: Reference to @D not found
Reference to @E (no group)
== Show default group

#print-glossary(
entry-list-3,
groups: ("",),
show-all: true,
)

== Show Group C and Group D

#print-glossary(
entry-list-3,
groups: ("Group C", "Group D"),
show-all: true,
)
22 changes: 22 additions & 0 deletions tests/debug/debug.typ
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,28 @@ Force long when empty defaults to plural: #glspl("potato A", long: true)

#gls-group("potato D")

== #count-refs

#context count-refs((key: "potato D"))

== #count-all-refs

All refs: #context count-all-refs()

Only list 4: #context count-all-refs(entry-list: entry-list-4)

== #there-are-refs

true: #context there-are-refs()

false: #context there-are-refs(groups: (" ",))

#context if there-are-refs(entry-list: ((key: "potato A"),)) [
There are refs to potato A in the document.
] else [
There are no refs to potato A in the document.
]

== test `__attribute_is_empty` error

// #gls-long("potato A")
Expand Down

0 comments on commit f350eb5

Please sign in to comment.