In the codly function there is an “inset” argument, however, setting it to 0.5em for example insets every line by that amount, how do I inset only the content relative to the outer border? I also tried with a
show raw.where(block: true) block.with(inset: 0.5em)
It might just be me, but to be honest I do not really understand what you mean by “content relative to the outer border”. So do you want to inset just a subset of the code? Or do you really mean the border of the whole code? Maybe try taking a screenshot and drawing something or edit the screenshot so it looks like you want it to look like.
basically I find the space between the numbering and the border and the text and the top (and bottom) borders to be too little, in the screenshot below you see that I inset the Python logo a bit by setting lang-outset: (x: -5pt, y: 5pt), I’m looking to do something similar for all the raw content. I don’t know if now it’s a bit clearer
This way is not really pretty and maybe there is a better way, but this is what I came up with:
You can change the number format like this: #codly(number-format: (n) => box(inset: (x: 9pt))[#text[#str(n)]]). The inset will increase the distance to the right border. For the top and bottom, you could just add a blank like in your code and change the numbering function so it does not display the number if it is the first or the last line. So the final example code would be as follows:
#import "@preview/codly:1.0.0": *
#show: codly-init.with()
#codly(zebra-fill: none)
#codly(lang-inset: 0.5em)
#codly(number-format: (n) => {
if n != 1 and n != 5 [
#box(inset: (x: 5pt, y: 0pt), width: 8pt)[#text[#str(n)]]
]
})
```rust
pub fn main() {
println!("Hello, world!");
}
``` // This comment is needed for the syntax in this forum
which looks like this:
The width: 8pt is needed, because the inset seems to go to the left and the right, so setting the width manually will decrease the gap between the numbering and the code. If you don’t mind the big gap, you can of course delete it again or increase the value.