Skip to content

Commit ff85320

Browse files
committed
Add print-gloss to print single entry.
Fixes #166.
1 parent 9e1a52c commit ff85320

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
> definition, whereas the long in `#gls(...)` refers to the "long form" of the
1313
> entry's output.
1414
15+
> [!TIP]
16+
> A new utility `print-gloss` has been added to allow printing the default's
17+
> formatting for a single entry. This is useful when you want to print
18+
> a single entry outside of `print-glossary`.
19+
> Fixes #166.
1520
1621
## 0.5.9
1722

glossarium.typ

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
make-glossary,
1515
register-glossary,
1616
reset-counts,
17+
print-gloss,
1718
print-glossary,
1819
gls-key,
1920
gls-short,
@@ -32,4 +33,5 @@
3233
Gls,
3334
Glspl,
3435
style-entries,
36+
//
3537
)

tests/print-gloss/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# generated by tytanic, do not edit
2+
3+
diff/**
4+
out/**

tests/print-gloss/ref/1.png

17.3 KB
Loading

tests/print-gloss/test.typ

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#import "../../themes/default.typ": *
2+
#let entry-list = (
3+
(key: "foo", description: "This is the foo entry."),
4+
(key: "bar", long: "longbar", description: "This is the bar entry."),
5+
(key: "baz"),
6+
(key: "qux"),
7+
)
8+
#register-glossary(entry-list)
9+
#show: make-glossary
10+
11+
#print-glossary(entry-list, show-all: true)
12+
13+
= Tests
14+
15+
@foo
16+
17+
@bar @qux
18+
19+
Reprint foo's entry.
20+
#print-gloss("foo")
21+
22+
Reprint bar's entry.
23+
#print-gloss("bar")

themes/default.typ

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,28 @@
16091609
use-key-as-short: use-key-as-short,
16101610
)
16111611

1612+
#let print-gloss(
1613+
key,
1614+
show-all: false,
1615+
disable-back-references: false,
1616+
deduplicate-back-references: false,
1617+
minimum-refs: 0, // Default to 0 to always print
1618+
description-separator: ": ",
1619+
user-print-title: default-print-title,
1620+
user-print-description: default-print-description,
1621+
user-print-back-references: default-print-back-references,
1622+
) = context default-print-gloss(
1623+
__get_entry_with_key(here(), key),
1624+
show-all: show-all,
1625+
disable-back-references: disable-back-references,
1626+
deduplicate-back-references: deduplicate-back-references,
1627+
minimum-refs: minimum-refs,
1628+
description-separator: description-separator,
1629+
user-print-title: user-print-title,
1630+
user-print-description: user-print-description,
1631+
user-print-back-references: user-print-back-references,
1632+
)
1633+
16121634
#let _print-glossary(
16131635
entry-list,
16141636
groups: (),

0 commit comments

Comments
 (0)