typst-community / glossarium

Glossarium is a simple typst glossary.
MIT License
29 stars 9 forks source link

Missing sorted method on dictionary #22

Closed stormofice closed 7 months ago

stormofice commented 7 months ago

Hello,

I can't get typst to work with glossarium.

Using this minimal example:

#import "@preview/glossarium:0.2.6": make-glossary, print-glossary, gls, glspl

#show: make-glossary

#print-glossary((
  (key: "os", short: "OS", long: "operating system")
))

I encounter the following issue:

error: type dictionary has no method `sorted`
   ┌─ @preview/glossarium:0.2.6/glossarium.typ:93:23
   │
93 │   for entry in entries.sorted(key: (x) => x.key) {
   │                        ^^^^^^

help: error occurred in this call of function `print-glossary`
  ┌─ thesis.typ:5:1
  │  
5 │   #print-glossary((
  │ ╭──^
6 │ │   (key: "os", short: "OS", long: "operating system")
7 │ │ ))
  │ ╰──^

I have tried it with the latest release version (0.10.0) and the nightly git release (typst 0.10.0 (e2e8159b)).

Am I missing something?

slashformotion commented 7 months ago

Typst has a weird syntax:

you need to add a , at the end of the line with the glossary entry (see below)

#import "@preview/glossarium:0.2.6": make-glossary, print-glossary, gls, glspl

#show: make-glossary

#print-glossary((
  (key: "os", short: "OS", long: "operating system"), // here
))

Since the function print-glossary expect a list of dicts, we are supposed to be able to sort that list.

stormofice commented 7 months ago

Thanks, that fixed it :)

Didn't know about this syntactic distinction