Skip to content

Commit

Permalink
Merge pull request #26 from ENIB-Community/refacto
Browse files Browse the repository at this point in the history
fix(printing): normalize entries before use
  • Loading branch information
slashformotion authored Apr 7, 2024
2 parents 82d69e4 + 5e9822e commit f3861a0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
Binary file modified examples/full-example/main.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/full-example/main.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/glossarium:0.2.6": make-glossary, print-glossary, gls, glspl
#import "../../glossarium.typ": make-glossary, print-glossary, gls, glspl
// Replace the local import with a import to the preview namespace.
// If you don't know what that mean, please go read typst documentation on how to import packages at https://typst.app/docs/packages/.

Expand Down
Binary file modified examples/import-terms-from-yaml-file/main.pdf
Binary file not shown.
21 changes: 16 additions & 5 deletions glossarium.typ
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ SOFTWARE.*/
body
}

#let print-glossary(entries, show-all: false, disable-back-references: false, group-pagebreak: false) = {
__glossary_entries.update(x => {
for entry in entries {
x.insert(
entry.key,
#let __normalize-entry-list(entry_list) = {
let new-list = ()
for entry in entry_list {
new-list.push(
(
key: entry.key,
short: entry.short,
Expand All @@ -77,6 +76,18 @@ SOFTWARE.*/
),
)
}
return new-list
}

#let print-glossary(entry_list, show-all: false, disable-back-references: false, group-pagebreak: false) = {
let entries = __normalize-entry-list(entry_list)
__glossary_entries.update(x => {
for entry in entry_list {
x.insert(
entry.key,
entry,
)
}

x
})
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ local:
mkdir -p ~/.local/share/typst/packages/local/glossarium/{{version}}
cp -r * ~/.local/share/typst/packages/local/glossarium/{{version}}

build-examples: local
find examples/* -type d -exec typst compile --root {} {}/main.typ \;
build-examples:
find examples/* -type d -exec bash -c "echo Compiling {} && typst compile --root . {}/main.typ" \;

# format typst code (use typstfmt)
fmt:
Expand Down

0 comments on commit f3861a0

Please sign in to comment.