How to use codelst or codly inside fletcher nodes?

Codelst is partially to blame here, because it wraps raw blocks in a zero-width container:

#let a = sourcecode[```c
void call_foo() {
    ...
}
```]

#context assert(measure(a).width == 0pt)

You can get around that by explicitly setting node widths, or by wrapping sourcecode blocks in a block of fixed width, etc. For example:

node(width: 5cm, sourcecode[```c
void caller() {
  call_foo();
  ...
}
```])

Alternatively, if you don’t need line numbers:

#import "@preview/fletcher:0.5.3" as fletcher: diagram, node, edge

#diagram(
  node-stroke: 1pt,
  edge-stroke: 1pt,
  node-shape: rect,
  {
  node(```c
  void caller() {
    call_foo();
    ...
  }
  ```)
  edge("-|>")
  node((1, 0), ```c
  void call_foo() {
    ...
  }
  ```)
})
1 Like