mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-03 16:41:27 +01:00
typst: a block of it in markdown is typeset on the server
A ```typst (or ```typ) block is compiled by the typst crate into SVG and
shown as an image where it stands, so math, tables and figures can be
written in typst beside the markdown around them. It shows its source while
it is set, and the error typst gives, with the block's line, when it cannot
be.
Each block is a document of its own: its source is the only file in its
world and the fonts are typst-assets', inside the binary, so nothing is read
from disk or fetched — packages and images are refused. The page fits what
is on it, is transparent, and carries the theme's text colour. Answers are
cached by source, two blocks are laid out at a time off the async threads,
and comemo's memo is evicted after each compile.
A share page asks POST /api/share/{token}/typst, which takes the reader's
cookie and typesets only a block the shared document holds.
typst brings a palette crate whose AsRef impls on arrays made four
`kek.as_ref().into()` in the vault ambiguous; they deref instead.
This commit is contained in:
1 parent
73ac961751
commit
0245402ead
34 files changed
+2295
-18
No files matched your search
@@ -250,6 +250,28 @@ $$
|
||||
The trace is the sum of the eigenvalues, $\\operatorname{tr} A = 4$, and the determinant their product, $\\det A = 3$.
|
||||
`,
|
||||
)
|
||||
await doc(
|
||||
algebra.id,
|
||||
'Spectral theorem',
|
||||
`A symmetric matrix is diagonalised by an orthonormal basis of eigenvectors.
|
||||
|
||||
\`\`\`typst
|
||||
#let A = $mat(2, 1; 1, 2)$
|
||||
$ A = Q Lambda Q^T, quad Q^T Q = I, quad Lambda = mat(3, 0; 0, 1) $
|
||||
|
||||
#table(
|
||||
columns: 3,
|
||||
stroke: 0.5pt + rgb("#545c52"),
|
||||
inset: 6pt,
|
||||
[*eigenvalue*], [*eigenvector*], [*multiplicity*],
|
||||
$3$, $1/sqrt(2) vec(1, 1)$, $1$,
|
||||
$1$, $1/sqrt(2) vec(1, -1)$, $1$,
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
The block above is typst; the rest of the page is markdown.
|
||||
`,
|
||||
)
|
||||
await doc(algebra.id, 'Exercise sheet 4', `- [x] 4.1 characteristic polynomial\n- [x] 4.2 diagonalise\n- [ ] 4.3 Jordan form\n`)
|
||||
const thesis = await folder(uni, 'thesis')
|
||||
await doc(thesis.id, 'Outline', `## Chapters\n\n1. Introduction\n2. Related work\n3. Method\n4. Evaluation\n`)
|
||||
@@ -388,6 +410,10 @@ await shot('editor')
|
||||
await open('/n/uni/linear-algebra/eigenvalues')
|
||||
await shot('math')
|
||||
|
||||
await open('/n/uni/linear-algebra/spectral-theorem')
|
||||
await sleep(1500)
|
||||
await shot('typst')
|
||||
|
||||
await open('/n/work')
|
||||
await keys('b')
|
||||
await sleep(800)
|
||||
|
||||
Reference in new issue
Block a user