The SRD, Unchained
1#let u(..args) = {
2 let size = args.at(0, default: 100%)
3 size * 0.65em
4}
5
6#let npcs-store = state("/5e/npcs", (:))
7#let item-store = state("/5e/items", (:))
8#let spell-store = state("/5e/spells", (:))
9
10#let insert-npc(
11 key,
12 name: [],
13 hit-die-num: 1,
14 hit-die-size: 8,
15 str: 10,
16 dex: 10,
17 con: 10,
18 int: 10,
19 wis: 10,
20 cha: 10,
21) = context {
22 let npcs = npcs-store.get()
23 npcs.insert(key, (
24 name: name,
25 str: str,
26 dex: dex,
27 con: con,
28 int: int,
29 wis: wis,
30 cha: cha,
31 ))
32 npcs-store.update(npcs)
33}
34
35#let base-template(content) = context {
36 // Typopgraphy
37 show title: set text(size: 2.2em)
38 show heading: set block(above: u(2), below: u(1))
39 show heading: set par(leading: u(0.5))
40 show heading: set text(bottom-edge: "baseline")
41 show heading.where(level: 1): set text(size: 2em)
42 show heading.where(level: 2): set text(size: 1.5em)
43 show heading.where(level: 3): set text(size: 1.5em)
44 show heading.where(level: 4): set text(size: 1.25em)
45
46 content
47
48 [ // Data for querying
49 #metadata((
50 npcs: npcs-store.final(),
51 ))<meta.srd-data>
52 ]
53}
54
55#let sidebar = block
56
57#let section-template(content) = {
58 set heading(offset: 1)
59 show heading.where(level: 3): set heading(outlined: false)
60
61 /// Typography
62 show heading.where(level: 3): box.with(
63 width: 100%,
64 stroke: (bottom: 0.3pt),
65 inset: (bottom: u(0.5)),
66 )
67 // Paragraphs
68 set par(justify: true, first-line-indent: 1em, spacing: u())
69 // Lists
70 show list: set par(spacing: u())
71
72 // Figures
73 show figure: set block(breakable: true)
74 set figure(numbering: none)
75 show figure: set text(weight: 500, number-type: "lining")
76 show strong: set text(weight: 400)
77 show figure: set align(start + top)
78 set figure.caption(position: top)
79 show figure.caption: strong
80 show figure.caption: set text(size: 1.1em)
81 show figure.where(supplement: [Sidebar]): block.with(
82 width: 100%,
83 inset: u(),
84 fill: white.transparentize(20%),
85 )
86 show figure.where(supplement: [Sidebar]): it => {
87 show figure.caption: set block(width: 100%)
88 it
89 }
90
91 // Tables
92 show figure.where(supplement: [Table]): it => {
93 show table: set par(justify: false)
94 set table(stroke: none, fill: (x, y) => {
95 if (calc.even(y)) { white.transparentize(20%) }
96 })
97
98 it
99 }
100
101 content
102}
103
104#let templates = (
105 base: base-template,
106 section: section-template,
107)