Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lynn/typst-syntree
Syntax trees for typst
https://github.com/lynn/typst-syntree
Last synced: 4 days 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-12T20:57:49.000Z (10 months ago)
- Last Synced: 2024-08-02T06:17:07.533Z (3 months ago)
- Language: Typst
- Size: 12.7 KB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
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]]]"
)
```![Output tree for "This is a wug"](https://github.com/lynn/typst-syntree/assets/16232127/d0c680b2-4fd0-420f-b350-9e9c96ac37f3)
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)))
```![Output tree of colors](https://github.com/lynn/typst-syntree/assets/16232127/bc979614-e2ce-4616-97d1-1584788fc71f)