This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.typ
331 lines (282 loc) · 7.67 KB
/
lib.typ
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#let metadata = toml("/metadata.toml")
#let title = metadata.title
#let paper = "iso-b5"
#let config = metadata.config
#let is-nightly = config.version == "NIGHTLY"
#let is-wip = config.wip
#let version = {
if config.version == "#{VERSION}#" or config.commit_sha == "#{COMMIT_SHA}#" {
"DEV"
} else {
if config.version == "NIGHTLY" {
config.commit_sha
} else {
config.version
}
}
}
#let version_url = if config.version_url == "#{VERSION_URL}#" { metadata.repo_url } else { config.version_url }
#let highlight-color-base = color.hsl(57deg, 100%, 47.6%).rotate(-5deg)
#let highlight-color = highlight-color-base.desaturate(10%).mix((white, 300%), space: oklab)
#let heading-color = highlight-color-base.saturate(-5%).mix((black, 33%), space: oklab)
#let table-heading-color = black
#let note-color = highlight-color-base.desaturate(10%).mix((white, 200%), space: oklab)
#let dark-note-color = yellow.mix((black, 66%), space: oklab)
#let paper-color = white
#let text-color = black
#let display-font = "Asul"
#let title-font = "Amarante"
#let primary-font = "Gentium Book Plus"
#let accent-font = "Alegreya Sans"
#let wip-banner = [
#place(top + center)[
#box(fill: highlight-color-base, inset: 4pt)[
#text(weight: "bold", fill: black)[Work In Progress]
]
]
]
#let label-page-num(locator, label) = {
locator(loc => {
let arr = query(label, loc)
arr.first().location().position().page
})
}
#let set-page-numbers() = {
locate(loc => {
set text(size: 10pt)
let page-number = [
#circle(radius: 1em, fill: highlight-color-base)[
#set align(center + horizon)
#counter(page).display("1")
]
]
if (config.media != "PRINT") [
#set align(center)
#page-number
] else {
if (calc.odd(loc.page())) [
#set align(left)
#page-number
] else [
#set align(right)
#page-number
]
}
})
}
#let load-stat(filename) = {
yaml("/stats/" + filename + ".yaml")
}
#let huge-title(content) = {
set align(center)
let fill = heading-color.rotate(-10deg).saturate(100%).darken(5%)
let stroke-width = (1pt / 2)
show heading: set text(font: title-font, size: 36pt, weight: 700, fill: fill, tracking: -1pt)
box(height: 12em)[
#set align(center + bottom)
#box(height: 100%, inset: (top: 2em))[
#set align(center + horizon)
#content
]
#line(length: 100%, stroke: stroke-width + fill)
#v(1.5pt, weak: true)
#line(length: 100%, stroke: stroke-width + fill)
]
}
#let large-title(content) = {
set align(center)
block(
width: 100%,
inset: (y: 1em),
)[
#set text(font: display-font, size: 14pt, weight: 700, fill: heading-color)
#upper(content)
]
}
#let item-title(content) = {
box(
inset: 4pt,
fill: highlight-color,
width: 100%,
)[
#set text(font: display-font, size: 11pt, weight: 700)
#set align(center)
#content
]
}
#let text-scale(amount, content) = {
set text(size: 1em * amount)
content
}
#let note-title(content) = {
set text(font: accent-font, weight: 600, size: 9pt, tracking: 0.05em)
set align(center + horizon)
box(width: 100%, upper(content))
v(1em, weak: true)
}
#let note(borderless: false, fill: note-color, content) = {
let stroke-width = 1pt
let hook-width = 3pt
let trapezoid = polygon(
fill: black,
(0%, 0pt),
(hook-width, hook-width),
(100% - hook-width, hook-width),
(100%, 0pt),
)
set text(size: 8pt)
block(breakable: false, width: 100%, [
#if borderless { none } else {
place(top + center, dy: stroke-width * -1, rotate(
0deg,
box(width: 100% + (hook-width * 2), height: hook-width, trapezoid),
))
place(bottom + center, dy: stroke-width, rotate(
180deg,
box(width: 100% + (hook-width * 2), height: hook-width, trapezoid),
))
}
#box(fill: fill, inset: 8pt, width: 100%)[#content]
])
}
#let lead(content) = {
text-scale(120%, emph(content))
}
#let hr = {
let stroke-width = (1pt / 2)
line(length: 100%, stroke: stroke-width + black)
v(1.5pt, weak: true)
line(length: 100%, stroke: stroke-width + black)
}
#let truth-list(..args) = {
list(marker: [○], ..args)
}
#let ts-link(..args, it) = {
underline(link(..args, it))
}
#let wrapper(doc) = [
#let outer-margin = 0.8cm
#let inner-margin = 1.4cm
#set document(title: title)
#set page(
paper: paper,
fill: paper-color,
margin: (
bottom: 1.5cm,
inside: if (config.media != "PRINT") { inner-margin } else { outer-margin },
outside: inner-margin,
top: 0.8cm,
),
header: if (config.wip) { wip-banner },
)
#show par: it => {
set par(justify: true)
it
}
#show outline.entry: it => {
set text(size: 9pt)
v(0pt, weak: true)
box(
inset: (left: 1em + 14pt * (it.level - 1)),
link(it.element.location(), [
#v(0pt, weak: true)
#upper(it.body)
#h(1fr)
#it.page
]),
)
}
#show outline.entry.where(level: 1): it => {
let stroke-width = (1pt / 4)
set text(size: 11pt, weight: "bold", font: display-font, fill: heading-color)
block(breakable: false)[
#link(it.element.location())[
#grid(columns: (1em + 10pt, 1fr), it.page, [
#set align(bottom)
#text-scale(85%, upper(it.body))
])
]
#v(4pt, weak: true)
#line(length: 100%, stroke: stroke-width + heading-color)
#v(2pt, weak: true)
#line(length: 100%, stroke: stroke-width + heading-color)
]
v(0pt, weak: true)
}
#set text(font: primary-font, size: 9pt, fill: text-color)
#show table: it => {
set table(stroke: none, align: left + horizon, fill: (col, row) => {
if row == 0 { white } else {
if calc.odd(row) { highlight-color } else { white }
}
})
it
}
#set list(marker: [‣])
#doc
]
#let table-title(wrapper: text, ..args, content) = {
box(
outset: (x: 0pt, y: 0pt),
inset: 4pt,
width: 100%,
fill: table-heading-color,
wrapper(..args, [
#show: it => {
set text(
font: accent-font,
weight: 800,
size: 10pt,
fill: white,
tracking: 0.05em,
)
set align(center + horizon)
upper(it)
}
#content
]),
)
}
#let cairn-stat-block(data) = {
let escape-str(str) = str.replace("\\", "\\\\").replace("#", "\#")
let markup-eval(str) = eval(escape-str(str), mode: "markup")
let hp = data.at("hp", default: 0)
let armor = data.at("armor", default: 0)
let str = data.at("str", default: 10)
let dex = data.at("dex", default: 10)
let wil = data.at("wil", default: 10)
let attacks = data.at("attacks", default: ()).join(", ")
let special = data.at("special", default: none)
let details = data.at("details", default: ())
let critical-damage = data.at("critical_damage", default: none)
let traits = data.at("traits", default: ())
let attrs = (
if str != 10 [#str STR] else { none },
if (dex != 10) [#dex DEX] else { none },
if (wil != 10) [#wil WIL] else { none },
).filter(el => el != none).join(", ")
let stat-line = (
if hp != 0 [#hp HP] else { none },
if armor != 0 [#armor Armor] else { none },
if attrs != none [#attrs] else { none },
if attacks != none {
for attack in attacks {
attack
}
},
if special != none { markup-eval(special) } else { none },
for trait in traits {
trait
},
).filter(el => el != none).join(", ")
set list(tight: true)
block(breakable: false)[
#stat-line
#for detail in details [
- #markup-eval(detail)
]
#if critical-damage != none [
- *Critical Damage:* #markup-eval(critical-damage)
]
]
}