Commands
This reference documents a custom command corresponding to the Typst compiler and its implementation of the Cmd
interface.
Typstry
Typstry.Commands.TypstCommand
— TypeTypstCommand(::Vector{String})
TypstCommand(::TypstCommand; kwargs...)
The Typst compiler and its parameters.
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`
Typstry.Commands.TypstError
— TypeTypstError <: Exception
TypstError(::TypstCommand)
An Exception
indicating a failure to run
a TypstCommand
.
Typstry.Commands.@typst_cmd
— Macro@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`
Typstry.Commands.julia_mono
— Constantjulia_mono
A constant String
file path to the JuliaMono typeface.
Use with a TypstCommand
and one of addenv
, setenv
, or the font-path
Typst command-line option.
Typstry.Commands.preamble
— Constantpreamble
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")
Typstry.Commands.render
— Functionrender(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 open
ed by the default viewer.
Examples
julia> render(Any[true 1; 1.2 1 // 2]);
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
Base.addenv
— Functionaddenv(::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`
Base.detach
— FunctionBase.eltype
— FunctionBase.firstindex
— FunctionBase.getindex
— FunctionBase.hash
— Functionhash(::TypstCommand, ::UInt)
See also TypstCommand
.
Base.ignorestatus
— Functionignorestatus(::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`
Base.iterate
— Methoditerate(::TypstCommand)
iterate(::TypstCommand, i)
See also TypstCommand
.
Examples
julia> iterate(typst`help`, 2)
("help", 3)
julia> iterate(typst`help`, 3)
Base.keys
— Functionkeys(::TypstCommand)
See also TypstCommand
.
Examples
julia> keys(typst`help`)
2-element LinearIndices{1, Tuple{Base.OneTo{Int64}}}:
1
2
Base.lastindex
— FunctionBase.length
— FunctionBase.run
— Functionrun(::TypstCommand, args...; kwargs...)
See also TypstCommand
.
Errors thrown by the Typst compiler will be printed to stderr
. Then, a Julia TypstError
will be thrown unless the ignorestatus
flag is set.
Base.setcpuaffinity
— Functionsetcpuaffinity(::TypstCommand, cpus)
See also TypstCommand
.
Examples
julia> setcpuaffinity(typst`help`, nothing)
typst`help`
Base.setenv
— Functionsetenv(::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`
Base.show
— Methodshow(::IO, ::MIME"text/plain", ::TypstCommand)
See also TypstCommand
.
Examples
julia> show(stdout, "text/plain", typst`help`)
typst`help`
Base.show
— Methodshow(::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));
Base.showerror
— Functionshowerror(::IO, ::TypstError)
Print a TypstError
when failing to run
a TypstCommand
.
Examples
julia> showerror(stdout, TypstError(typst``))
TypstError: failed to `run` a `TypstCommand(String[])`