forked from AugustinWinther/codedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.typ
More file actions
56 lines (47 loc) · 1.41 KB
/
lib.typ
File metadata and controls
56 lines (47 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#let code(
code,
lang: "py",
font-size: 9pt,
border-size: 0.13em,
border-color: luma(170),
line-color-1: luma(250),
line-color-2: luma(240),
) = {
// Change how raw.line looks
show raw.line: line => {
// Constants
let first-line-num = 1
let last-line-num = line.count
let inset-y = font-size/4
let line-height = 2*inset-y + font-size
let stroke = border-color + border-size
let get-stroke(line-num) = {
if line-num == first-line-num { return ( top: stroke, x: stroke) }
else if line-num == last-line-num { return (bottom: stroke, x: stroke) }
else { return (x: stroke) }
}
let get-radius(line-num) = {
if line-num == first-line-num { return ( top: 1em) }
else if line-num == last-line-num { return (bottom: 1em) }
else { return (0em) }
}
let get-fill(line-num) = {
if calc.even(line-num) { return line-color-2 }
else { return line-color-1 }
}
block(
breakable: false,
height: line-height,
width: 100%,
inset: (x: inset-y*2, y: inset-y),
fill: get-fill(line.number),
radius: get-radius(line.number),
stroke: get-stroke(line.number),
spacing: -0.4em,
text(size: font-size)[#line.body]
)
}
// Display raw content using custom design defined above
v(2*0.4em) // Compensate for spacing: -0.4em
raw(code, lang: lang)
}