Skip to content

Commit 19b1b62

Browse files
authored
Merge pull request #12 from kilpkonn/main
Fix codelst for typst 0.11
2 parents 1d569aa + ea1a755 commit 19b1b62

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

codelst.typ

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
// Numbering function
211211
let next-lno() = {
212212
codelst-counter.step()
213-
codelst-counter.display((lno) => [
213+
context codelst-counter.display((lno) => [
214214
#if lno >= numbers-first and calc.rem(lno - numbers-first, numbers-step) == 0 [
215215
#numbers-style(codelst-numbering(numbering, lno))
216216
]
@@ -237,28 +237,26 @@
237237
columns: if numbering == none {
238238
(1fr,)
239239
} else if numbers-side != right {
240-
(numbers-width, 1fr)
240+
(numbers-width, gutter, 1fr)
241241
} else {
242-
(1fr, numbers-width)
242+
(1fr, gutter, numbers-width)
243243
},
244-
column-gutter: gutter,
244+
column-gutter: 0pt,
245245
row-gutter: 0pt,
246246

247247
stroke:none,
248248
inset: (x: 0pt, y: .25em),
249249

250250
fill: (c, r) => {
251-
r = calc.quo(r, 2) // Fix for column / row numbers counting gutters
252251
if r + numbers-start in highlighted {
253252
highlight-color
254253
} else {
255254
none
256255
}
257256
},
258257
align: (c, r) => {
259-
// c = calc.quo(c, 2)
260258
if numbering != none {
261-
if numbers-side != right and c == 0 or (numbers-side == right and c == 1) {
259+
if numbers-side != right and c == 0 or (numbers-side == right and c == 2) {
262260
return numbers-align
263261
}
264262
}
@@ -268,9 +266,9 @@
268266
..if numbering == none {
269267
code-lines
270268
} else if numbers-side != right {
271-
code-lines.map((l) => (next-lno(), l)).flatten()
269+
code-lines.map((l) => (next-lno(), none, l)).flatten()
272270
} else {
273-
code-lines.map((l) => (l, next-lno())).flatten()
271+
code-lines.map((l) => (l, none, next-lno())).flatten()
274272
}
275273
)
276274
})
@@ -321,7 +319,7 @@
321319
#let lineref( label, supplement:"line" ) = locate(loc => {
322320
let lines = query(selector(label), loc)
323321
assert.ne(lines, (), message: "Label <" + str(label) + "> does not exists.")
324-
[#supplement #numbering("1", ..codelst-counter.at(lines.first().location()))]
322+
[#supplement #numbering("1", ..context codelst-counter.at(lines.first().location()))]
325323
})
326324

327325
#let codelst-styles( body ) = {

0 commit comments

Comments
 (0)