knot is not knitr — Literate programming for Typst, powered by Rust.
Knot lets you write R and Python code directly inside Typst documents. The code executes, and the results — text, plots, tables — flow into your document automatically. Think RMarkdown or Quarto, but with Typst instead of LaTeX and a Rust engine underneath.
- Multi-language — R and Python in the same document, running in parallel
- Smart caching — SHA-256 chained hashes; only changed chunks re-execute
- Live preview — chunk-by-chunk streaming preview in VS Code as code runs
- Rich output — plots (SVG/PNG), DataFrames as Typst tables, inline expressions
- Bidirectional sync — click in the PDF to jump to the source, and vice versa
- Full IDE support — completion, hover docs, diagnostics, formatting (Air + Ruff + Tinymist)
curl -sSf https://raw.githubusercontent.com/knot-literate-programming/knot/master/install.sh | bashThe script downloads the prebuilt binaries for your platform, installs the VS Code extension, and checks that all prerequisites (Typst, Tinymist, R, Python, Air, Ruff) are in place.
Prerequisites:
| Tool | Purpose | Required? |
|---|---|---|
| Typst | Compiles .typ → PDF |
Yes |
| Tinymist | Powers the VS Code preview | Yes |
| R | Executes R chunks | If using R |
| Python | Executes Python chunks | If using Python |
| Air | R code formatter in VS Code | Recommended |
| Ruff | Python code formatter in VS Code | Recommended |
Build from source
git clone https://github.com/knot-literate-programming/knot.git
cd knot
cargo install --path crates/knot-cli
cargo install --path crates/knot-lspThen install the VS Code extension:
cd editors/vscode && npm install && npm run package
code --install-extension knot-*.vsixknot init my-project
cd my-project
code . # open in VS Code, then click "Start Preview"A .knot file is a Typst document with executable code blocks:
#import "lib/knot.typ": *
= My Analysis
```{r}
#| label: summary
x <- c(2, 4, 6, 8, 10)
summary(x)
```
The mean is `{r} mean(x)` and the standard deviation is `{r} round(sd(x), 2)`.
```{python}
import matplotlib.pyplot as plt
plt.plot([1, 4, 9, 16])
plt.title("Growth")
typst(current_plot())
```Compile to PDF:
knot build # one-shot PDF
knot watch # rebuild on saveKnot compiles .knot files through a three-pass pipeline:
- Plan — parse, compute SHA-256 hashes, classify each chunk as
Skip/CacheHit/MustExecute - Execute — run R and Python chains in parallel; cache results
- Assemble — interleave outputs with source text to produce a
.typfile for Typst
The VS Code extension shows a streaming preview: cache hits appear instantly, and each chunk updates the preview as it finishes executing.
knot-literate-programming.github.io/knot
- User guide — installation, chunk options, VS Code, CLI reference
- Developer guide — architecture, adding a language executor, LSP internals
We welcome bug reports, feature requests, and pull requests. See CONTRIBUTING.md for setup instructions and guidelines.
@software{Klutchnikoff_Knot_2026,
author = {Klutchnikoff, Nicolas},
title = {{Knot: Literate programming for Typst}},
url = {https://github.com/knot-literate-programming/knot},
version = {0.3.0},
year = {2026}
}See CITATION.cff for full metadata.
Apache License 2.0 — see LICENSE. Inspired by knitr, Quarto, and Typst.