#Lexically sorted outline

7 messages · Page 1 of 1 (latest)

jade blade
#

I'm trying to make an outline where the outline heading entries are sorted lexically instead of by their location. (Why? Because of an old joke book I'm rewriting in Typst).
I cannot for the life of me figure out how to modify the list of entries (or even how one would access it) used by the outline, I know how to target specific heading depths, or target specific kinds, but that is the extend of my knowledge.

My first idea was to query all level 1 headings (the ones I care about), sort them and then somehow used them in an outline function, but that fell in the wash.

Ideally a solution might space the entries above each new lexical symbol, buts that's second to it actually working

#

Lexically sorted outline

chrome hedge
#

I think you might need to use a custom solution and not the outline function. The outline allows changing target but not the order

thorny scaffold
#

you may be finding the label view which sorts and groups labels in entire workspace.

jade blade
#

Okay, I dropped the outline like bluess said, and formatted it muslef instead, which seems to work

context {
  let chapters = query(
    heading.where(
      level: 1,
      outlined: true,
    )
  ).sorted(key: ch => lower(ch.body.text))
  for chapter in chapters {
    let loc = chapter.location()
    let nr = counter(heading).at(loc).first()
    link(
      loc, 
      [ #chapter.body, #nr \ ],
    )
  }
}

Although, now I've run into a fun issue with the text-field of heading bodies not being accessible when headings have special math or other styled content in them. Which is fun, as the outline function seems to handle the cases.
I guess I have to manually provide keys in such cases, or customise (and figure the structures out) even more...

chrome hedge
#

yeah that's another reason why outline doesn't sort I guess, it can't, the heading title is just content 🙂

#

You could create some sort of elaborate solution where you provide a sort key for every heading