I am experimenting with preparing a checklist, and then being able to scan the print and identify whether particular items are checked off. (Think poor man’s optical multiple choice bubble sheets.)
To draw and locate the circle is straight-forward:
#circle(radius: 10mm)<my_circle>
#context [
circle location: #locate(<my_circle>).position()
]<circle_locator>
However, when I introspect from the command-line using typst query test.typ "<circle_locator>", hoping to be able to pick out a value, it only returns that <circle_locator> is a context.
#circle(radius: 10mm)<my_circle>
#context [
// Just wrap it inside anything that can be queried
#metadata(
(
circle-location: locate(<my_circle>).position()
)
)<circle_locator> // Moved the label inside of the context block
]
The inner expression creates a dictionary, in this case with the single key circle-location. I was just mimicking the text you had before. You could also put the location directly into the metadata.