How can I show code listings from codly in "Code snippets" outline?

Hey there,

is there any possibility to show Code snippets in a outline. I have some code snippet like this:

#figure(
    [```rust
    fn main() {
        println!("Hello World");
    }
    ```],
    caption: [Hello World in Rust]
)

In the outline I tried to work with the target: figure.where(kind: ...) thingy, but did not find the right kind.

I would be really thankful for some suggestions on this topic.

Greetings
John

If you are aiming to specifically select your listings, you should assign a custom kind to your figures.
A POC would be

#show outline.entry: it => {
  it
  align(center, rect(stroke: stroke(dash: "dotted"), it.element))
}

#outline(target: figure.where(kind: raw))

#let f = figure(
    [```rust
    fn main() {
        println!("Hello World");
    }
    ```],
    caption: [Hello World in Rust],
)
#f

1 Like

The kind associated to code listings is raw. You don’t need to set it explicitly on the figures, but for a custom outline, the target would then be figure.where(kind: raw).

3 Likes

Sometimes I forget how straightforward things are in Typst :sweat_smile:

Thank you both for your blazingly fast reply. Every time I am more amazed by how straightforward typst is.