-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsvelte.config.ts
More file actions
82 lines (75 loc) · 2.21 KB
/
Copy pathsvelte.config.ts
File metadata and controls
82 lines (75 loc) · 2.21 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
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
import adapter from '@sveltejs/adapter-static'
import type { Config } from '@sveltejs/kit'
import { mdsvex } from 'mdsvex'
import { importAssets } from 'svelte-preprocess-import-assets'
import { heading_ids } from 'svelte-widgets/heading-anchors'
import { katex_preprocess } from 'svelte-widgets/katex'
import { starry_night_highlighter } from 'svelte-widgets/live-examples'
const macros: Record<string, string> = {
// Infinitesimal differential (used in derivatives and integrals)
'\\dif': `\\mathrm d`,
// Vector
'\\vec': `{\\boldsymbol{#1}}`,
// Matrix
'\\mat': `{\\boldsymbol{#1}}`,
// Real line
'\\reals': `{\\mathbb{R}}`,
// Complex plane
'\\comps': `{\\mathbb{C}}`,
// Integers
'\\ints': `{\\mathbb{Z}}`,
// Expectation value
'\\expect': `\\mathbb{E}`,
// Variance
'\\var': `\\operatorname{var}`,
// Matrix diagonal
'\\diag': `\\operatorname{diag}`,
// Unit/identity matrix
'\\unity': `\\mat{\\mathbb{I}}`,
// Used in equations to hide non-essential constants
'\\const': `\\text{const}`,
// Absolute value
'\\abs': `\\left|#1\\right|`,
// Adaptive parentheses
'\\paren': `\\mathopen{}\\left(#1\\right)\\mathclose{}`,
// Adaptive brackets
'\\brkt': `\\mathopen{}\\left[#1\\right]\\mathclose{}`,
// Adaptive curly brackets
'\\cbrkt': `\\mathopen{}\\left\\{#1\\right\\}\\mathclose{}`,
}
for (let index = 65; index <= 90; index++) {
const letter = String.fromCodePoint(index)
// Caligraphic letters
macros[`\\${letter}cal`] = `\\mathcal{${letter}}`
// Blackboard bold letters
macros[`\\${letter}bb`] = `\\mathbb{${letter}}`
}
const katex = katex_preprocess({ macros, errorColor: `#cc0000` })
export default {
extensions: [`.svelte`, `.svx`, `.md`],
preprocess: [
katex.before,
mdsvex({
extensions: [`.svx`, `.md`],
highlight: { highlighter: starry_night_highlighter },
}),
katex.after,
heading_ids(),
importAssets({
sources: (default_sources) => [
...default_sources,
{
tag: `a`,
srcAttributes: [`href`],
filter: ({ attributes }) => attributes.href.endsWith(`.pdf`),
},
],
}),
],
kit: {
adapter: adapter(),
alias: {
$root: `.`,
},
},
} satisfies Config