How to produce two glossaries from one dictionary or source file?

You can also do something like this:

#let transform-glossary(data, swap: false) = if swap {
  data
    .map(entry => array
      .zip(entry.long, entry.description)
      .map(((long, description)) => (
        key: long,
        long: emph(entry.key),
        description: if description != [] [#description],
      )))
    .flatten()
} else {
  data.map(entry => (
    key: entry.key,
    long: array
      .zip(entry.long, entry.description)
      .map(((long, description)) => {
        emph(long) + if description != [] [: #description]
      })
      .join[; ],
    description: none,
  ))
}.sorted(key: entry => entry.key)
1 Like