#Referencing headers with computed labels

9 messages · Page 1 of 1 (latest)

kindred dagger
#

This works:

#set heading(numbering: "1.")

= Heading <ab>

@ab

But this does not:

#set heading(numbering: "1.")

= Heading #label("a" + "b")

@ab

The latter program fails with error: cannot reference text. I'm guessing that the #label is being associated with the string "Heading" rather than the entire heading syntax node. Is that the issue? If so, how do I resolve the ambiguity?

#

This works, but I'm wondering if there's a simpler solution.

#set heading(numbering: "1.")

#[= Heading] #label("a" + "b")

@ab
storm vault
#

it's not obvious but you can put it on the next line

#

?render ```
#set heading(numbering: "1.")

= Heading
#label("a" + "b")

Reference to @ab

kindred dagger
#

Ah good to know! Is there a particular reason why <label> parses differently than #label(..)?

storm vault
#

no idea

#

well, I imagine <label> having dedicated syntax means you can ensure the common case is ergonomic, whereas #label is parsed and evaluated like a normal function

#

and because it attaches to the previous thing it isn't quite compatible with having it inline in headings