Internals
This reference documents non-public utilities.
Typstry.compile_workload
— Functioncompile_workload(examples)
Given an iterable of value-type pairs, interpolate each value into a @typst_str
within a PrecompileTools.@compile_workload
block.
Typstry.unwrap
— Functionunwrap(io, type, key)
unwrap(io, type, key, default)
Strings
Typstry.Strings
— ModuleStrings
The Julia to Typst interface, a custom string corresponding to Typst source text, and its implementation of the String
interface.
Examples
julia> Typstry.Strings
Typstry.Strings
Typstry.Strings.examples
— Constantexamples
A constant Vector
of Julia values and their corresponding Type
s implemented for show_typst
.
Typstry.Strings.typst_mime
— Constanttypst_mime
Equivalent to MIME"text/typst"()
.
Examples
julia> Typstry.Strings.typst_mime
MIME type text/typst
Typstry.Strings.backticks
— Functionbackticks(io)
Examples
julia> Typstry.Strings.backticks(IOContext(stdout, :backticks => 3))
3
Typstry.Strings.block
— Functionblock(io)
Examples
julia> Typstry.Strings.block(IOContext(stdout, :block => true))
true
Typstry.Strings.code_mode
— Functioncode_mode(io)
Print the number sign, unless mode(io) == code
.
Examples
julia> Typstry.Strings.code_mode(IOContext(stdout, :mode => code))
julia> Typstry.Strings.code_mode(IOContext(stdout, :mode => markup))
#
julia> Typstry.Strings.code_mode(IOContext(stdout, :mode => math))
#
Typstry.Strings.depth
— Functiondepth(io)
Examples
julia> Typstry.Strings.depth(IOContext(stdout, :depth => 0))
0
Typstry.Strings.enclose
— Functionenclose(f, io, x, left, right = reverse(left); kwargs...)
Call f(io, x; kwargs...)
between printing left
and right
, respectfully.
Examples
julia> Typstry.Strings.enclose((io, i; x) -> print(io, i, x), stdout, 1, "\$ "; x = "x")
$ 1x $
Typstry.Strings.escape
— Functionescape(io, n)
Print \
to io
n
times.
Examples
julia> Typstry.Strings.escape(stdout, 2)
\\
Typstry.Strings.indent
— Functionindent(io)
Examples
julia> Typstry.Strings.indent(IOContext(stdout, :tab_size => 2))
" "
Typstry.Strings.join_with
— Functionjoin_with(f, io, xs, delimeter; kwargs...)
Similar to join
, except printing with f(io, x; kwargs...)
.
Examples
julia> Typstry.Strings.join_with((io, i; x) -> print(io, -i, x), stdout, 1:4, ", "; x = "x")
-1x, -2x, -3x, -4x
Typstry.Strings.math_mode
— Functionmath_mode(f, io, x; kwargs...)
Typstry.Strings.math_pad
— Functionmath_pad(io)
Return ""
, "\$"
, or "\$ "
depending on the block
and mode
settings.
Examples
julia> Typstry.Strings.math_pad(IOContext(stdout, :mode => math))
""
julia> Typstry.Strings.math_pad(IOContext(stdout, :block => true, :mode => markup))
"\$ "
julia> Typstry.Strings.math_pad(IOContext(stdout, :block => false, :mode => markup))
"\$"
Typstry.Strings.mode
— Functionmode(io)
Examples
julia> Typstry.Strings.mode(IOContext(stdout, :mode => code))
code::Mode = 0
Typstry.Strings.parenthesize
— Functionparenthesize(io)
Examples
julia> Typstry.Strings.parenthesize(IOContext(stdout, :parenthesize => true))
true
Typstry.Strings.show_array
— Functionshow_array(io, x)
Typstry.Strings.show_parameters
— Functionshow_parameters(io, f, keys, final)
Examples
julia> Typstry.Strings.show_parameters(
IOContext(stdout, :depth => 0, :tab_size => 2, :delim => typst"\"(\""),
"vec", [:delim, :gap], true)
vec(
delim: "(",
Typstry.Strings.show_raw
— Functionshow_raw(f, io, x, language)
Typstry.Strings.show_vector
— Functionshow_vector(io, x)
Dates.jl
A Dates.jl package extension would currently print warnings during precompilation. See also the Julia issue #52511
Typstry.Strings.date_time
— Functiondate_time(::Union{Dates.Date, Dates.Time, Dates.DateTime})
Typstry.Strings.duration
— Functionduration(::Dates.Period)
Examples
julia> Typstry.Strings.duration(Dates.Day(1))
:days
julia> Typstry.Strings.duration(Dates.Hour(1))
:hours
Typstry.Strings.dates
— Functiondates(::Union{Dates.Date, Dates.DateTime, Dates.Period, Dates.Time})
Examples
julia> Typstry.Strings.dates(Dates.Date(1))
("datetime", (:year, :month, :day), (1, 1, 1))
julia> Typstry.Strings.dates(Dates.Day(1))
("duration", (:days,), (TypstText{String}("1"),))
Commands
Typstry.Commands
— ModuleCommands
A custom command corresponding to the Typst compiler and its implementation of the Cmd
interface.
Examples
julia> Typstry.Commands
Typstry.Commands
Typstry.Commands.default_preamble
— Constantdefault_preamble
Typstry.Commands.apply
— Functionapply(f, tc, args...; kwargs...)
Typstry.Commands.format
— Functionformat(::Union{MIME"application/pdf", MIME"image/png", MIME"image/svg+xml"})
Return the image format acronym corresponding to the given MIME
.
Examples
julia> Typstry.Commands.format(MIME"application/pdf"())
"pdf"
julia> Typstry.Commands.format(MIME"image/png"())
"png"
julia> Typstry.Commands.format(MIME"image/svg+xml"())
"svg"