Commands

This reference documents a custom command corresponding to the Typst compiler and its implementation of the Cmd interface.

Typstry

Typstry.Commands.TypstCommandType
TypstCommand(::Vector{String})
TypstCommand(::TypstCommand; kwargs...)

The Typst compiler and its parameters.

Info

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

Examples

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

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

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

This does not 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.preambleConstant
preamble

A constant TypstString used at the beginning of Typst source files.

Examples

julia> println(Typstry.Commands.preamble)
#set page(margin: 1em, height: auto, width: auto, fill: white)
#set text(16pt, font: "JuliaMono")
source
Typstry.Commands.renderFunction
render(x;
    input = "input.typ",
    output = "output.pdf",
    open = true,
    preamble = Typstry.preamble,
context...)

Render to a document using show(::IO, ::MIME"text/typst", ::Typst).

This first generates the input file containing the preamble and formatted value. Then it is compiled to the output document, whose format is inferred by its file extension to be pdf, png, or svg. The document may be automatically opened by the default viewer.

Examples

julia> render(Any[true 1; 1.2 1 // 2]);
source

Base

Base.:==Function
==(::TypstCommand, ::TypstCommand)

See also TypstCommand.

Examples

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

julia> typst`help` == ignorestatus(typst`help`)
false
source
Base.addenvFunction
addenv(::TypstCommand, args...; kwargs...)

See also TypstCommand and julia_mono.

Examples

julia> addenv(typst`compile input.typ output.pdf`, "TYPST_FONT_PATHS" => julia_mono)
typst`compile input.typ output.pdf`
source
Base.ignorestatusFunction
ignorestatus(::TypstCommand)

Return a TypstCommand that does not throw a TypstError if the Typst compiler throws an error.

Errors thrown by the Typst compiler are printed to stderr regardless.

Examples

julia> ignorestatus(typst`help`)
typst`help`
source
Base.iterateMethod
iterate(::TypstCommand)
iterate(::TypstCommand, i)

See also TypstCommand.

Examples

julia> iterate(typst`help`, 2)
("help", 3)

julia> iterate(typst`help`, 3)
source
Base.keysFunction
keys(::TypstCommand)

See also TypstCommand.

Examples

julia> keys(typst`help`)
2-element LinearIndices{1, Tuple{Base.OneTo{Int64}}}:
 1
 2
source
Base.setenvFunction
setenv(::TypstCommand, args...; kwargs...)

See also TypstCommand and julia_mono.

Examples

julia> setenv(typst`compile input.typ output.pdf`, "TYPST_FONT_PATHS" => julia_mono)
typst`compile input.typ output.pdf`
source
Base.showMethod
show(::IO, ::MIME"text/plain", ::TypstCommand)

See also TypstCommand.

Examples

julia> show(stdout, "text/plain", typst`help`)
typst`help`
source
Base.showMethod
show(::IO, ::Union{
    MIME"application/pdf", MIME"image/png", MIME"image/svg+xml"
}, ::Union{Typst, TypstString, TypstText})

Print the Portable Document Format (PDF), Portable Network Graphics (PNG), or Scalable Vector Graphics (SVG) format.

The preamble keyword parameter used by render may be specified in an IOContext. Environments, such as Pluto.jl notebooks, may use these methods to display values of type Typst, TypstString, and TypstText.

Examples

julia> show(IOContext(devnull, :preamble => typst""), "image/svg+xml", Typst(1));
source