Yeah, I think Codly is not meant to be used with custom raw show rules. I also had an issue when I tried to do similar stuff. I even tried using __codly-raw, but it doesn’t work, because it’s meant to be use on raw element and not any content, like in the custom show rule you show. So I think you’re better off recreating parts of Codly yourself or finding other packages. showybox is good. Initially I hand-rolled my frame and layout, but it was absolutely horribly written, so at some point I switched to showybox, but it was still messy, so I finally just switched to Codly, and I like it.
You can open an issue in its repository and ask if there can be a solution for this.
I like the idea actually, I am thinking of adding a “transformer” API to allow people to “transform” content, but I don’t know how and where to include it. The problem of your show rule is that it does not produce a new raw block. You should use raw line show rules: Typst
Thank you for your reply (and also for this wonderful package)!
I would like to use syntax highlighting that is normally applied for the lang setting sh (except it should be isolated from $ and #).
When I try editing the project you shared on my machine in order to achieve that, I get the error maximum show rule depth exceeded. I modified line 24 like so:
#show raw: set text(font: "DejaVu Sans Mono", size: 1.11em)
#show raw.where(lang: "console"): it => {
show raw.line: it => {
let user = emph(("$ "))
let root = emph(("# "))
it
.text
.split("\n")
.map(line => {
let starts(pattern) = line.starts-with(pattern)
let prefix = if starts("$ ") { user } else if starts("# ") { root }
let text = line.replace(regex("^[$#] "), "")
- prefix + text
+ prefix + raw(text, lang: "sh")
})
.join("\n")
}
it
}
The only remaining thing I’m wondering about is how to make the font size the same as for other codly raw blocks. I’m noticing that both in the screenshot (and also on my machine, after I compile the code), that the font size is slightly bigger, which is especially noticable when I compare the word console on the right between the two snippets.
(Setting size exactly to 1.11em was my idea, originating from the other thread about regular (non-Codly) raw blocks, as it looked very similar in size to vanilla raw blocks.)