The characters |
and >
both are their own operator, which are probably defined with a higher priority in the syntax. Thus, when applying the syntax highlighting, The |
and >
characters are styled separately, leading to two separate text nodes, which makes ligatures impossible. You can see this when using a show rule like
#show raw: it => repr(it.lines)
where the code
```r
foo |> bar
buz -> test('|>')
```
is then converted to the lines
line(
body: sequence(
[foo ],
styled(child: [|], ..), // These characters are
styled(child: [>], ..), // styled separately.
styled(child: [ bar], ..),
),
..
),
line(
body: sequence(
[buz ],
styled(child: [->], ..), // These are styled together.
styled(child: [ ], ..),
styled(child: [test], ..),
styled(child: [(], ..),
styled(child: ['], ..),
styled(child: [|>], ..), // These are styled together.
styled(child: ['], ..),
styled(child: [)], ..),
),
..
)
Different languages then differ in this behaviour as they may define their operators with different priorities, such that e.g. |>
comes before |
and >
. This also explains, why the ligature works inside a string, as the whole string is styled in a single text node.