Why does `supplement: auto` pre-calculate the supplement?

Hi,

Please somebody with better understanding of Typst internals enlighten me about this one.

I have a simple reference like this:

#set heading(numbering: "1")
= My heading <myheading>
See @myheading.

The output of typst query test.typ "<myheading>" is surprising for me:

[
  {
    "func": "heading",
    "level": 1,
    "depth": 1,
    "offset": 0,
    "numbering": "1",
    "supplement": {
      "func": "text",
      "text": "Section"
    },
    "outlined": true,
    "bookmarked": "auto",
    "hanging-indent": "auto",
    "body": {
      "func": "text",
      "text": "My heading"
    },
    "label": "<myheading>"
  }
]

I would expect supplement to be auto, but it is pre-calculated. This makes scripting a bit harder because You have to check for language specific default values to see if the reference was called with supplement: auto or something else.

Am I misunderstanding something here? Is there a good reason for this behavior?

Thanks,

This is because Typst query returns the ‘synthesized’ fields. Synthesis is a step in the current evaluation model that happens before any show/set rules and is not meant to be exposed to the user, so is poorly documented.

Synthesis is probably going to be refactored out of the language, but its status is uncertain. There was a PR by @MDLC01, but it was closed because it needs more design work (like so many things :face_exhaling:). See this comment by Laurenz and the discussion above.

1 Like