1. Introduction
  2. Guidance
  3. 1. Get started
  4. 2. Bundles
    1. 2.1. All-in-One Library for Browsers
    2. 2.2. All-in-One Library for Node.js
  5. 3. Compilers
    1. 3.1. (Pre-)Compiler in CLI
    2. 3.2. Compiler in Rust
    3. 3.3. Compiler in Node.js
    4. 3.4. Compiler in Wasm (Web)
  6. 4. Renderers
    1. 4.1. Renderer in Rust
    2. 4.2. Renderer in Node.js
    3. 4.3. Renderer in Wasm (Web)
    4. 4.4. Renderer in React
    5. 4.5. Renderer in Solid
    6. 4.6. Renderer in Angular
    7. 4.7. Renderer in Vue3
    8. 4.8. Hexo Plugin
  7. 5. Samples
    1. 5.1. Static, Responsive rendering
    2. 5.2. Streaming, Incremental rendering
    3. 5.3. Serverless rendering
  8. 6. Trouble Shooting
  9. Project samples
  10. 8. shiroa
  11. 9. typst-preview
  12. 10. hexo-renderer-typst
  13. References
  14. 13. Routing to Renferences

reflexo-typst Documentation

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