Commands

This reference documents how to interact with the Typst compiler.

Typstry.Commands.TypstCommandErrors.TypstCommandErrorType
TypstCommandError <: Exception
TypstCommandError(::TypstCommand)

An Exception indicating a Typst comand-line interface error from running a TypstCommand.

Interface

Implements the Exception interface.

  • showerror(::IO, ::TypstCommandError)
  • show(::IO, ::MIME"text/plain", ::TypstCommandError)

Examples

julia> TypstCommandError(typst``)
TypstCommandError(typst``)
source
Typstry.Commands.TypstCommands.TypstCommandType
TypstCommand(::AbstractVector{<:AbstractString})
TypstCommand(::TypstCommand; kwargs...)

The Typst compiler and its parameters.

Keyword parameters have the same semantics as for a Cmd.

Interface

This type implements the Cmd interface. However, the interface is undocumented, which may result in unexpected behavior.

  • addenv(::TypstCommand, env...; inherit::Bool = true)
  • detach(::TypstCommand)
  • eltype(::Type{TypstCommand})
  • firstindex(::TypstCommand)
  • getindex(::TypstCommand, i)
  • hash(::TypstCommand, ::UInt)
  • ignorestatus(::TypstCommand)
    • Do not throw a TypstCommandError if the Typst compiler throws an error. Errors thrown by the Typst compiler are printed to stderr regardless.
  • iterate(::TypstCommand, i)
  • iterate(::TypstCommand)
  • keys(::TypstCommand)
  • lastindex(::TypstCommand)
  • length(::TypstCommand)
  • read(::TypstCommand, ::Type{String})
  • read(::TypstCommand)
  • run(::TypstCommand, args...; wait::Bool = true)
    • Errors thrown by the Typst compiler will be printed to stderr. Then, a Julia TypstCommandError will be thrown unless the ignorestatus flag is set.
  • setcpuaffinity(::TypstCommand, cpus)
  • setenv(::TypstString, env...; kwargs...)
    • Can be used with julia_mono.
  • show(::IO, ::MIME"text/plain", ::TypstCommand)

Examples

julia> help = TypstCommand(["help"])
typst`help`

julia> TypstCommand(help; ignorestatus = true)
typst`help`
source
Typstry.Commands.TypstCommands.@typst_cmdMacro
@typst_cmd("")
typst``

Construct a TypstCommand where each parameter is separated by a space.

This does not yet support interpolation; use the constructor instead.

Examples

julia> typst`help`
typst`help`

julia> typst`compile input.typ output.typ`
typst`compile input.typ output.typ`
source
Typstry.Commands.julia_monoConstant
julia_mono

A constant String file path to the JuliaMono typeface.

This typeface is available when using one of the following approaches:

  • TypstCommand(["compile", "input.typ", "output.pdf", "--font-path=" * julia_mono])
  • addenv(::TypstCommand, "TYPST_FONT_PATHS" => julia_mono)
  • setenv(::TypstCommand, "TYPST_FONT_PATHS" => julia_mono)
  • ENV["TYPST_FONT_PATHS"] = julia_mono

and when compiling documents with the following methods:

  • render
  • typst
  • show with the application/pdf, image/png, and image/svg+xml MIME types and a TypstString, TypstText, and Typst value

See also TypstCommand.

source
Typstry.Commands.typstFunction
typst(::AbstractString; catch_interrupt::Bool = true, ignorestatus::Bool = true)

Convenience function intended for interactive use, emulating the typst command line interface.

If the "TYPST_FONT_PATHS" environment variable is not set, it is temporarily set to julia_mono.

Warning

It strictly splits on spaces and does not provide any shell-style escape mechanism, so it will not work if there are, e.g., filenames with spaces.

Parameters

  • catch_interrupt::Bool = true
    • [CTRL]+[C] quietly quits the command.
  • ignorestatus::Bool = true
source