emulating code-line-numbers

Why?

Quarto’s built-in code-line-numbers is the common-case shortcut for “fade in some lines as I talk.” code-line-style is a superset — same look from the mark style in the emphasis preset.

The mapping is one-for-one. Reach for code-line-style when you outgrow it (custom colors, multiple styles per step, the diff preset, labels…).

The built-in for reference

```{r}
#| code-line-numbers: "3-5"
df |>
  filter(cyl == 6) |>
  group_by(gear) |>
  summarise(m = mean(mpg)) |>
  arrange(desc(m))
```
df |>
  filter(cyl == 6) |>
  group_by(gear) |>
  summarise(m = mean(mpg)) |>
  arrange(desc(m))

Range — code-line-numbers="3-5"

```{.r code-line-style="mark:3-5" code-line-style-preset="emphasis"}
df |>
  ...
```
df |>
  filter(cyl == 6) |>
  group_by(gear) |>
  summarise(m = mean(mpg)) |>
  arrange(desc(m))

Disparate lines — code-line-numbers="2,4"

```{.r code-line-style="mark:2, mark:4" code-line-style-preset="emphasis"}
df |>
  ...
```
df |>
  filter(cyl == 6) |>
  group_by(gear) |>
  summarise(m = mean(mpg)) |>
  arrange(desc(m))

Progressive — code-line-numbers="|3|4-5"

```{.r code-line-style="|mark:3|mark:4-5" code-line-style-preset="emphasis"}
df |>
  ...
```

Press → to walk through.

df |>
  filter(cyl == 6) |>
  group_by(gear) |>
  summarise(m = mean(mpg)) |>
  arrange(desc(m))

Where code-line-style goes further

You can pick a different color, stack styles, or attach a label — things code-line-numbers can’t do:

```{r}
#| code-line-style:
#|   styles:
#|     warn: { bg: "#ffd4d4", gutter: "#c00", marker: "!" }
#|   steps:
#|     - mark: 2
#|     - warn: { line: 4, label: "this is the bottleneck" }
```
df |>
  filter(cyl == 6) |>
  group_by(gear) |>
  summarise(m = mean(mpg)) |>
  arrange(desc(m))