tinymist/crates/typlite
Joseph Wilson 850852fc3b
fix: don't ignore user inputs in typlite (#2164)
I noticed that existing inputs specified on the command line such as
`typlite --input key-value ..` are ignored.

Test this as follows:
```zsh
$ echo '#sys.inputs' > test.typ
$ typlite test.typ --input key=value
```
Before this PR:
```zsh
$ cat typ.md
`(x-target: "md")`
```
After this PRL
```zsh
$ cat typ.md
`(key: "value", x-target: "md")`
```

---------

Co-authored-by: Myriad-Dreamin <camiyoru@gmail.com>
2025-10-21 17:18:01 +08:00
..
src fix: don't ignore user inputs in typlite (#2164) 2025-10-21 17:18:01 +08:00
Cargo.toml feat: warning collector and logging for diagnostics in typlite (#2180) 2025-10-16 18:18:57 +08:00
dist.toml build: enable typlite distribution in dist.toml (#1810) 2025-06-12 18:05:37 +08:00
README.md build: update readme docs (#2114) 2025-09-12 00:50:56 +08:00

Typlite

Converts a subset of typst to markdown.

Installation

Install prebuilt binaries via shell script

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Myriad-Dreamin/tinymist/releases/download/v0.13.26-rc1/typlite-installer.sh | sh

Install prebuilt binaries via powershell script

powershell -ExecutionPolicy Bypass -c "irm https://github.com/Myriad-Dreamin/tinymist/releases/download/v0.13.26-rc1/typlite-installer.ps1 | iex"

Usage

# default output is main.md
typlite main.typ
# specify output
typlite main.typ output.md

Supported format:

  • output.txt: Plain text
  • output.md: Markdown
  • output.tex: LaTeX
  • output.docx: Word

Todo: We may support custom format by typst scripting in future, like:

# specify output
typlite main.typ --post-process @preview/typlite-mdx output.mdx

Feature

  • Contexual Content Rendering: Contents begin with context keyword will be rendered as svg output. The svg output will be embedded inline in the output file as base64 by default, if the --assets-path parameter is not specified. Otherwise, the svg output will be saved in the specified folder and the path will be embedded in the output file.

Typlite-Specific sys.inputs

The sys.input.x-target can be used distinguish with normal HTML export.

#let x-target = sys.inputs.at("x-target", default: "pdf")

#let my-function = if x-target == "md" {
  md-impl
} else {
  pdf-impl or html-impl
}