diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 85f1826..9f23eb0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -7,8 +7,6 @@ on: - master pull_request: types: [opened, synchronize, reopened] - workflow_dispatch: - branches: [ '**' ] jobs: build-example: diff --git a/README.md b/README.md index 3d9ffbf..2d50aab 100644 --- a/README.md +++ b/README.md @@ -43,35 +43,62 @@ A term is a [dictionary](https://typst.app/docs/reference/types/dictionary/) com - `short` (string) *required*: the short form of the term replacing the term citation. - `long` (string or content) *optional*: The long form of the term, displayed in the glossary and on the first citation of the term. - `desc` (string or content) *optional*: The description of the term. +- `plural` (string or content) *optional*: The pluralized short form of the term. +- `longplural` (string or content) *optional*: The pluralized long form of the term. - `group` (string) *optional, case-sensitive*: The group the term belongs to. The terms are displayed by groups in the glossary. Then the terms are passed as a list to `print-glossary` ```ts -#print-glossary(( - // minimal term - (key: "kuleuven", short: "KU Leuven"), - // a term with a long form and a group - (key: "unamur", short: "UNamur", long: "Namur University", group: "Universities"), - // another one but formated differently - ( - key: "umons", - short: "UMons", - long: "Mons University", - group: "Universities" - ), - // no long form here - (key: "kdecom", short: "KDE Community", desc:"An international team developing and distributing Open Source software."), - // a full term with description containing markup - ( - key: "oidc", - short: "OIDC", - long: "OpenID Connect", - desc: [OpenID is an open standard and decentralized authentication protocol promoted by the non-profit - #link("https://en.wikipedia.org/wiki/OpenID#OpenID_Foundation")[OpenID Foundation].], - group: "Accronyms", - ), -)) +#print-glossary( + ( + // minimal term + (key: "kuleuven", short: "KU Leuven"), + + // a term with a long form and a group + (key: "unamur", short: "UNamur", long: "Namur University", group: "Universities"), + + // another one but formated differently + ( + key: "umons", + short: "UMons", + long: "Mons University", + group: "Universities" + ), + + // no long form here + (key: "kdecom", short: "KDE Community", desc:"An international team developing and distributing Open Source software."), + + // a term with a markup description + ( + key: "oidc", + short: "OIDC", + long: "OpenID Connect", + desc: [OpenID is an open standard and decentralized authentication protocol promoted by the non-profit + #link("https://en.wikipedia.org/wiki/OpenID#OpenID_Foundation")[OpenID Foundation].], + group: "Accronyms", + ), + + // a term with a short plural + ( + key: "potato", + short: "potato", + // "plural" will be used when "short" should be pluralized + plural: "potatoes", + desc: [#lorem(10)], + ), + + // a term with a short plural + ( + key: "dm", + short: "DM", + long: "diagonal matrix", + // "longplural" will be used when "long" should be pluralized + longplural: "diagonal matrices", + desc: "Probably some math stuff idk", + ), + ) +) ``` By default, the terms that are not referenced in the document are not shown in the glossary, you can force their appearance by setting the `show-all` argument to true. @@ -99,14 +126,15 @@ Referencing terms is done using the key of the terms using the `gls` function or #### Handling plurals -You can use the `glspl` function and the references supplements to pluralize terms: +You can use the `glspl` function and the references supplements to pluralize terms. +The `plural` key will be used when `short` should be pluralized and `longplural` will be used when `long` should be pluralized. If the `plural` key is missing then glossarium will add an 's' at the end of the short form as a fallback. ```ts -#glspl("oidc") // equivalent of `#gls("oidc", suffix: "s")` -// or -@oidc[s] +#glspl("potato") ``` +Please look at the examples regarding plurals. + #### Overriding the text shown You can also override the text displayed by setting the `display` argument. @@ -117,7 +145,7 @@ You can also override the text displayed by setting the `display` argument. ## Final tips -I recommend setting a show rule for the links to that your reader understand that they can click on the references to go to the term in the glossary. +I recommend setting a show rule for the links to that your readers understand that they can click on the references to go to the term in the glossary. ```ts #show link: set text(fill: blue.darken(60%)) @@ -126,6 +154,10 @@ I recommend setting a show rule for the links to that your reader understand tha ## Changelog +### Unreleased + +- Added support for plurals, see [examples/plural-example](examples/plural-example) + ### 0.3.0 - Introducing support for grouping terms in the glossary. Use the optional and case-sensitive key `group` to assign terms to specific groups. The appearanceof the glossary can be customized with the new parameter `enable-group-pagebreak`, allowing users to insert page breaks between groups for better organization. These enhancements were contributed by [indicatelovelace](https://github.com/indicatelovelace). diff --git a/examples/full-example/main.pdf b/examples/full-example/main.pdf index 0fca183..1454d36 100644 Binary files a/examples/full-example/main.pdf and b/examples/full-example/main.pdf differ diff --git a/examples/groups/groups.pdf b/examples/groups/groups.pdf index 862836a..985c428 100644 Binary files a/examples/groups/groups.pdf and b/examples/groups/groups.pdf differ diff --git a/examples/import-terms-from-yaml-file/main.pdf b/examples/import-terms-from-yaml-file/main.pdf index a2c9091..0ea4dca 100644 Binary files a/examples/import-terms-from-yaml-file/main.pdf and b/examples/import-terms-from-yaml-file/main.pdf differ diff --git a/examples/plural-example/main.pdf b/examples/plural-example/main.pdf index 334e1f3..faa9fba 100644 Binary files a/examples/plural-example/main.pdf and b/examples/plural-example/main.pdf differ diff --git a/glossarium.typ b/glossarium.typ index b49ce10..2a91b04 100644 --- a/glossarium.typ +++ b/glossarium.typ @@ -50,8 +50,9 @@ SOFTWARE.*/ } } -// reference to term with pluralisation +// Reference to term with pluralisation #let glspl(key, long: none) = { + let suffix = "s" context { let __glossary_entries = __glossary_entries.final(here()) if key in __glossary_entries { @@ -59,10 +60,10 @@ SOFTWARE.*/ let gloss = __query_labels_with_key(here(), key, before: true) - let suffix = "s"; let is_first = gloss == () let entlongplural = entry.at("longplural", default: ""); let entlong = if entlongplural == [] or entlongplural == "" { + // if the entry long plural is not provided, then fallback to adding 's' suffix let entlong = entry.at("long", default: ""); if entlong != [] and entlong != "" { [#entlong#suffix]