Claim: the Typst compiling functions is provided by official typst
The unique feature of typst-ts-cli
is that it precompiles typst documents into Vector Format files. It internally runs Typst compiler with typst.ts
's exporters.
// The './main.sir.in' could be obtained by `typst-ts-cli`
// Specifically, by `compile ... --format vector`
const vectorData: Uint8Array = await
fetch('./main.sir.in').into();
// into svg format
await $typst.svg({ vectorData });
// into canvas operations
await $typst.canvas(div, { vectorData });
// The './main.sir.in' could be obtained by `typst-ts-cli`
// Specifically, by `compile ... --format vector`
const vectorData: Uint8Array = await
fetch('./main.sir.in').into();
// into svg format
await $typst.svg({ vectorData });
// into canvas operations
await $typst.canvas(div, { vectorData });
For more usage of Vector Format files, please refer to Renderers section.
Installation
Install latest CLI of typst.ts via cargo:
cargo install --locked --git https://github.com/Myriad-Dreamin/typst.ts typst-ts-cli
cargo install --locked --git https://github.com/Myriad-Dreamin/typst.ts typst-ts-cli
Or Download the latest release from GitHub Releases.
The compile command
Typical usage
compile a document to a PDF file and a Vector Format file.
typst-ts-cli compile \
--workspace "fuzzers/corpora/math" \
--entry "fuzzers/corpora/math/main.typ"
typst-ts-cli compile \
--workspace "fuzzers/corpora/math" \
--entry "fuzzers/corpora/math/main.typ"
-e,--entry
option, required
Entry file.
typst-ts-cli -e main.typ
typst-ts-cli -e main.typ
-w,--workspace
option, default: .
Path to typst workspace.
typst-ts-cli -w /repos/root/ -e main.typ
typst-ts-cli -w /repos/root/ -e main.typ
--watch
option
Watch file dependencies and compile the document.
typst-ts-cli compile ... --watch
typst-ts-cli compile ... --watch
--format
option
compile a document to specific formats.
# export nothing (dry compile)
typst-ts-cli compile ... --format nothing
# into vector format
typst-ts-cli compile ... --format vector
# into multiple formats at the same time
typst-ts-cli compile ... --format svg --format svg_html
# export nothing (dry compile)
typst-ts-cli compile ... --format nothing
# into vector format
typst-ts-cli compile ... --format vector
# into multiple formats at the same time
typst-ts-cli compile ... --format svg --format svg_html
--dynamic-layout
option
Please setup the variables package before compilation.
typst-ts-cli package link --manifest \
repos/typst.ts/contrib/templates/variables/typst.toml
typst-ts-cli compile ... --dynamic-layout
typst-ts-cli package link --manifest \
repos/typst.ts/contrib/templates/variables/typst.toml
typst-ts-cli compile ... --dynamic-layout
-o,--output
option
Output to directory, default in the same directory as the entry file.
typst-ts-cli compile ... -o dist
typst-ts-cli compile ... -o dist
--trace
option
Comma separated options to trace execution of typst compiler when compiling documents:
# trace events at warning level
typst-ts-cli compile ... --trace=verbosity=0
# trace events at info level
typst-ts-cli compile ... --trace=verbosity=1
# trace events at debug level
typst-ts-cli compile ... --trace=verbosity=2
# trace events at trace level
typst-ts-cli compile ... --trace=verbosity=3
# trace events at warning level
typst-ts-cli compile ... --trace=verbosity=0
# trace events at info level
typst-ts-cli compile ... --trace=verbosity=1
# trace events at debug level
typst-ts-cli compile ... --trace=verbosity=2
# trace events at trace level
typst-ts-cli compile ... --trace=verbosity=3
Example: compile a document with watching dependencies
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--watch
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--watch
Example: compile a document into SVG
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--format svg
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--format svg
Example: compile a document into SVG wrapped with HTML
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--format svg_html
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--format svg_html
Example: compile a document into the Vector Format
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--format vector
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--format vector
Example: compile a document into the Vector Format containing responsive layouts
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--dynamic-layout
typst-ts-cli compile \
-e "fuzzers/corpora/math/main.typ"
--dynamic-layout
CLI Options
Help:
$ typst-ts-cli --help
The cli for typst.ts.
Usage: typst-ts-cli [OPTIONS] [COMMAND]
Commands:
compile Run compiler. [aliases: c]
completion Generate shell completion script
env Dump Client Environment.
font Commands about font for typst.
help Print this message or the help of the given subcommand(s)
package Commands about package for typst.
Options:
-V, --version Print Version
--VV <VV> Print Version in format [default: none] [possible values: none, short, features, full, json, json-plain]
-h, --help Print help
$ typst-ts-cli --help
The cli for typst.ts.
Usage: typst-ts-cli [OPTIONS] [COMMAND]
Commands:
compile Run compiler. [aliases: c]
completion Generate shell completion script
env Dump Client Environment.
font Commands about font for typst.
help Print this message or the help of the given subcommand(s)
package Commands about package for typst.
Options:
-V, --version Print Version
--VV <VV> Print Version in format [default: none] [possible values: none, short, features, full, json, json-plain]
-h, --help Print help