add code line number

This commit is contained in:
Jean-Marie Mineau 2025-09-01 10:28:09 +02:00
parent 8647a69ffb
commit 184c03b204
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2

View file

@ -179,7 +179,19 @@
// ---------- LISTING ----------
show raw.where(block: true): it => {
block(radius: 1em, fill: luma(240), inset: 1em, width: 80%, {
// Line number, not verry good (cannot copy code whitout line number)
// see https://github.com/typst/typst/issues/344
show raw.line: line => {
if line.number < 10 {
text(fill: gray)[~#line.number]
} else {
text(fill: gray)[#line.number]
}
h(1em)
line.body
}
block(radius: 1em, fill: luma(240), inset: 1em, width: 90%, {
set align(left)
it
})