https://github.com/lynn/typst-syntree
Syntax trees for typst
https://github.com/lynn/typst-syntree
Last synced: about 1 month ago
JSON representation
Syntax trees for typst
- Host: GitHub
- URL: https://github.com/lynn/typst-syntree
- Owner: lynn
- License: mit
- Created: 2023-07-06T15:41:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-21T15:05:35.000Z (5 months ago)
- Last Synced: 2025-02-14T08:22:19.458Z (3 months ago)
- Language: Typst
- Size: 14.6 KB
- Stars: 29
- Watchers: 3
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-typst - typst-syntree - Syntax trees for typst (Templates & Libraries / Linguistics)
README
# typst-syntree
**syntree** is a typst package for rendering syntax trees / parse trees (the kind linguists use).
The name and syntax are inspired by Miles Shang's [syntree](https://github.com/mshang/syntree). Here's an example to get started:
```typ
#import "@preview/syntree:0.2.0": syntree#syntree(
nonterminal: (font: "Linux Biolinum"),
terminal: (fill: blue),
child-spacing: 3em, // default 1em
layer-spacing: 2em, // default 2.3em
"[S [NP This] [VP [V is] [^NP a wug]]]"
)
```
There's limited support for formulas inside nodes; try `#syntree("[DP$zws_i$ this]")` or `#syntree("[C $diameter$]")`.
For more flexible tree-drawing, use `tree`:
```typ
#import "@preview/syntree:0.2.0": tree#let bx(col) = box(fill: col, width: 1em, height: 1em)
#tree("colors",
tree("warm", bx(red), bx(orange)),
tree("cool", bx(blue), bx(teal)))
```