Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93a7794c2e
|
||
|
|
40cc652aeb
|
||
|
|
05a66f4956
|
||
|
|
df889d8d72 | ||
|
|
c008b5bd86
|
||
|
|
842166c211
|
No files matched your search
+8
-4
@@ -41,7 +41,7 @@ different goals:
|
||||
### Import the package
|
||||
|
||||
```typst
|
||||
#import "@preview/glossy:0.5.0": *
|
||||
#import "@preview/glossy:0.5.1": *
|
||||
```
|
||||
|
||||
### Defining Glossary Terms
|
||||
@@ -186,8 +186,9 @@ Display the glossary using the `glossary()` function:
|
||||
|
||||
```typst
|
||||
#glossary(
|
||||
title: "Web Development Glossary", // Optional: defaults to Glossary
|
||||
theme: my-theme, // Optionaal: defaults to theme-twocol
|
||||
title: "Web Development Glossary", // Optional: defaults to Glossary theme:
|
||||
my-theme, // Optional: defaults to theme-academic
|
||||
sort: true, // Optional: whether or not to sort the glossary
|
||||
ignore-case: false, // Optional: ignore case when sorting terms
|
||||
groups: ("Web") // Optional: Filter to specific groups
|
||||
)
|
||||
@@ -252,7 +253,7 @@ Customize glossary appearance by defining a theme with three functions:
|
||||
// Individual glossary entry
|
||||
entry: (entry, index, total) => {
|
||||
// index = entry index, total = total entries in group
|
||||
let output = [#entry.short]
|
||||
let output = [#entry.short#entry.label] // **NOTE:** Label here!
|
||||
if entry.long != none {
|
||||
output = [#output -- #entry.long]
|
||||
}
|
||||
@@ -279,6 +280,9 @@ Entry fields available to themes:
|
||||
- `label`: Term's dictionary label
|
||||
- `pages`: Linked page numbers where term appears
|
||||
|
||||
**NOTE:** If the theme does not emit `entry.label`, linking form terms to their
|
||||
glossary entry will not work.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
watchexec \
|
||||
--watch . \
|
||||
--clear \
|
||||
--ignore 'tests/**/diff/**' \
|
||||
--ignore 'tests/**/out/**' \
|
||||
"typst-test r"
|
||||
+12
-7
@@ -541,6 +541,7 @@
|
||||
#let glossary(
|
||||
title: "Glossary",
|
||||
theme: theme-academic,
|
||||
sort: true,
|
||||
ignore-case: false,
|
||||
groups: (),
|
||||
) = context {
|
||||
@@ -601,13 +602,17 @@
|
||||
group = if group == none { "" } else { group }
|
||||
|
||||
// sort entries by case insensitivity if requested
|
||||
let sorted_entries = current_entries
|
||||
// 1. create array of tuples with (lower [if ignore-case], entry)
|
||||
.map(e => { if ignore-case { (lower(e.short), e) } else { (e.short, e) } })
|
||||
// 2. sort the tuples (by first element then second)
|
||||
.sorted(key: t => t.first())
|
||||
// 3. strip away the tuple's first element, leaving an array of entries
|
||||
.map(t => t.last())
|
||||
let sorted_entries = if sort {
|
||||
current_entries
|
||||
// 1. create array of tuples with (lower [if ignore-case], entry)
|
||||
.map(e => { if ignore-case { (lower(e.short), e) } else { (e.short, e) } })
|
||||
// 2. sort the tuples (by first element then second)
|
||||
.sorted() // NOTE: sorted() is NOT language-aware
|
||||
// 3. strip away the tuple's first element, leaving an array of entries
|
||||
.map(t => t.last())
|
||||
} else {
|
||||
current_entries
|
||||
}
|
||||
|
||||
// add entries to this group's output map
|
||||
output.insert(group, sorted_entries)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
grid(
|
||||
columns: (1fr, auto),
|
||||
gutter: 0.75em,
|
||||
[#short-display#long-display#description],
|
||||
[#short-display#long-display#description#entry.label],
|
||||
text(fill: rgb("#666666"), entry.pages)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
grid(
|
||||
columns: (1fr, auto),
|
||||
gutter: 1em,
|
||||
[#short-display#entry.label#long-display#description],
|
||||
[#short-display#entry.label#long-display#description#entry.label],
|
||||
[#entry.pages]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
},
|
||||
|
||||
entry: (entry, index, total) => {
|
||||
(entry.short, entry.long, entry.description, entry.pages)
|
||||
(entry.short + entry.label, entry.long, entry.description, entry.pages)
|
||||
}
|
||||
)
|
||||
@@ -203,7 +203,7 @@
|
||||
|
||||
if is_acronym {
|
||||
// Use acronym rules
|
||||
let first_char = upper_word.slice(0,1)
|
||||
let first_char = upper_word.codepoints().slice(0,1).first()
|
||||
if acronym_vowels.contains(first_char) {
|
||||
"an"
|
||||
} else {
|
||||
@@ -211,7 +211,7 @@
|
||||
}
|
||||
} else {
|
||||
// Non-acronym rules
|
||||
let first_char = lower_word.slice(0,1)
|
||||
let first_char = lower_word.codepoints().slice(0,1).first()
|
||||
|
||||
// Special cases for words matching a set of known 'silent h' prefixes
|
||||
let silent_h_words = (
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
@@ -0,0 +1,45 @@
|
||||
#import "/lib.typ": *
|
||||
#import "@preview/glossarium:0.5.1": *
|
||||
|
||||
#set page(height: auto, width: 4.5in)
|
||||
#show link: set text(fill: red)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
= `glossy`:
|
||||
|
||||
#box(
|
||||
stroke: 1pt,
|
||||
inset: 1em,
|
||||
[
|
||||
#show: init-glossary.with((WWW: "World Wide Web"))
|
||||
|
||||
This should be a link: @WWW
|
||||
|
||||
This should be a link, too: @WWW
|
||||
|
||||
#glossary()
|
||||
]
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
= `glossarium`:
|
||||
|
||||
#box(
|
||||
stroke: 1pt,
|
||||
inset: 1em,
|
||||
[
|
||||
#show: make-glossary
|
||||
#let entry-list = (
|
||||
(key: "ML", short: "ML", long: "Machine Learning"),
|
||||
)
|
||||
#register-glossary(entry-list)
|
||||
|
||||
This should be a link: @ML
|
||||
|
||||
This should be a link, too: @ML
|
||||
|
||||
#print-glossary(entry-list)
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
first:
|
||||
short: "DAL"
|
||||
long: "first"
|
||||
|
||||
second:
|
||||
short: "cab"
|
||||
long: "second"
|
||||
|
||||
third:
|
||||
short: "delta"
|
||||
long: "third"
|
||||
|
||||
fourth:
|
||||
short: "COO"
|
||||
long: "fourth"
|
||||
|
||||
fifth:
|
||||
short: "cuckoo"
|
||||
long: "fifth"
|
||||
|
||||
sixth:
|
||||
short: "ČR"
|
||||
long: "sixth"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 183 KiB |
@@ -0,0 +1,13 @@
|
||||
#import "/lib.typ":*
|
||||
|
||||
#show: init-glossary.with(yaml("glossary.yml"))
|
||||
|
||||
@first, @second, @third, @fourth, @fifth, @sixth
|
||||
|
||||
#glossary(ignore-case: false, sort: true)
|
||||
#line(length: 20em)
|
||||
#glossary(ignore-case: true, sort: true)
|
||||
#line(length: 20em)
|
||||
#glossary(ignore-case: false, sort: false)
|
||||
#line(length: 20em)
|
||||
#glossary(ignore-case: true, sort: false)
|
||||
@@ -0,0 +1,23 @@
|
||||
cab:
|
||||
short: "cab"
|
||||
long: "taxi cab"
|
||||
|
||||
coo:
|
||||
short: "COO"
|
||||
long: "Chief Operations Officer"
|
||||
|
||||
cuckoo:
|
||||
short: "cuckoo"
|
||||
long: "really crazy"
|
||||
|
||||
delta:
|
||||
short: "delta"
|
||||
long: "difference between two values"
|
||||
|
||||
dal:
|
||||
short: "DAL"
|
||||
long: "Delta Airlines"
|
||||
|
||||
čr:
|
||||
short: "ČR"
|
||||
long: "Česká Republika"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 133 KiB |
@@ -0,0 +1,20 @@
|
||||
#import "/lib.typ":*
|
||||
|
||||
#set text(lang: "cs", region: "CZ")
|
||||
|
||||
#show: init-glossary.with(yaml("glossary.yml"))
|
||||
#glossary(ignore-case: true, theme: theme-twocol)
|
||||
|
||||
#line(length: 20em)
|
||||
|
||||
@čr
|
||||
|
||||
@cab
|
||||
|
||||
@coo
|
||||
|
||||
@cuckoo
|
||||
|
||||
@delta
|
||||
|
||||
@dal
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "glossy"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
entrypoint = "lib.typ"
|
||||
authors = ["Stephen Waits <steve@waits.net>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in new issue
Block a user