How do I change size and color of line numbering in codly?

I know that the codly function accepts a number-format argument, but what would be the best way of making the numbering grey on a light grey background to better differentiate them from the actual code?

Because I did not find a specific parameter for the styling of the numbering (apart from the the number-function argument), I tried to do something with that.
There might be a more elegant way, but this is what I came up with:

#import "@preview/codly:1.0.0": *
#show: codly-init.with()
#codly(zebra-fill: none)

#codly(number-format: (n) => box(fill: luma(240))[#text(luma(100))[#str(n)]])

```rust
pub fn main() {
    println!("Hello, world!");
}
``` // This comment is just because of formatting in the forum...

The result:
grafik

I can imagine this is not really what you are looking for, but maybe better than nothing for now. If you have questions about the code or something, feel free to ask :)

1 Like

yes this kinda works, although I was thinking more of having the entire column where the numbers lie being light gray, kinda like you see in most text editors, I’m not really sure if there is a way to do so though but yours is already a good start, thanks for the suggestion!

I don’t know how to do that. I tried setting the height of the box, but then codly just adds space in between the lines. I looked through the documentation (of codly) briefly and I don’t think it is a thing at the moment. You could add a feature request/issue on github though so it might be added in the future.
In case you are still thinking about changing the size of the numbers, here is an updated version with bigger text and bigger text highlighting:

#import "@preview/codly:1.0.0": *
#show: codly-init.with()
#codly(zebra-fill: none)

#codly(number-format: (n) => box(fill: luma(240), height: 1.5em, inset: 0.5em)[#text(luma(100), size: 1.5em)[#str(n)]])

```rust
pub fn main() {
    println!("Hello, world!");
}
``` // This comment is just because of formatting in the forum...

I overlooked the size part because it was only in the headline. Sry for that :blush:

1 Like

I actually found a way on accident :joy:
You can add the outset property to the box (not inset) like this:

#import "@preview/codly:1.0.0": *
#show: codly-init.with()
#codly(zebra-fill: none)

#codly(number-format: (n) => box(fill: luma(240), height: 1.5em, outset: 0.5em)[#text(luma(100), size: 1.5em)[#str(n)]])

```rust
pub fn main() {
    println!("Hello, world!");
}
``` // you know the drill ;)

The result:
grafik
The outset does not effect the layout (so the surrounding styling) which makes it perfect for you usecase. It actually adds outset in the x and the y direction, so you might want to do something like outset: (x: 0.5em, y: 1em) depending on the size you want your numbering to be.
I’m still kind of a nooby as well, but now I got it :)

1 Like

That’s kinda awesome, I like how hacky it is, thank you very much! I think this is a very popular style for raw blocks, I’ll look into making an issue on the codly Github about it

edit:

In practice, this approach breaks a bit easily but I don’t think there currently is a better way to do this, I’ll probably avoid the grey background for the moment