Repository navigation
Within selector for introspection - #8250
Conversation
selector.within|
Does it mean that for document-aware outlines in bundle export we can now write #show document: it => context {
outline(target: selector(heading).within(here()))
it.body
} |
|
Not quite like that because you're discarding the document element, but in principle something like that can work yes. Alternatively, you can also directly use the document's location with #let local-outline() = context {
let doc = query(selector(document).before(here())).last()
outline(target: selector(heading).within(doc.location()))
}
#document("a.pdf")[
#local-outline()
= A
= B
]
#document("b.pdf")[
#local-outline()
= C
= D
= E
]Worth saying that querying documents is not the best for incremental compilation ... it's not a disaster, but the outline will likely be recomputed for every edit to the document its contained in. |
|
Awesome, thank you! What would a better way with respect to incremental compilation look like? |
Something that doesn't let the introspection observe the document's body. Internally, there is something like |
fix: adapt selector routes for typst/typst#8250 test
fix: adapt selector routes for typst/typst#8250 test
fix: adapt selector routes for typst/typst#8250 test
fix: adapt selector routes for typst/typst#8250 test
fix: adapt selector routes for typst/typst#8250 test
fix: adapt selector routes for typst/typst#8250 test
This selector is super useful, so I don't want to hold it back even though it's currently only supported in introspections, not in show rules. It's the same as
beforeandafterin this regard, but unlike these, it can be supported in show rules in the future.Closes #1926. The show rule part will be tracked in #8251.