Internals

This reference documents non-public utilities.

Info

A Dates.jl package extension would currently print warnings during precompilation. See also the Julia issue #52511

Contexts

Utilities

Typstry.compile_workloadFunction
compile_workload(examples)

Given an iterable of value-type pairs, interpolate each value into a @typst_str within a PrecompileTools.@compile_workload block.

source
Typstry.encloseFunction
enclose(f, io, x, left, right = reverse(left); kwargs...)

Call f(io, x; kwargs...) between printing left and right, respectfully.

Examples

julia> Typstry.enclose((io, i; x) -> print(io, i, x), stdout, 1, "\$ "; x = "x")
$ 1x $
source
Typstry.join_withFunction
join_with(f, io, xs, delimeter; kwargs...)

Similar to join, except printing with f(io, x; kwargs...).

Examples

julia> Typstry.join_with((io, i; x) -> print(io, -i, x), stdout, 1:4, ", "; x = "x")
-1x, -2x, -3x, -4x
source

Strings

Typstry.datesFunction
dates(::Union{Dates.Date, Dates.DateTime, Dates.Period, Dates.Time})

Examples

julia> Typstry.dates(Dates.Date(1))
("datetime", (:year, :month, :day), (1, 1, 1))

julia> Typstry.dates(Dates.Day(1))
("duration", (:days,), (TypstText{String}("1"),))
source
Typstry.durationFunction
duration(::Dates.Period)

Examples

julia> Typstry.duration(Dates.Day(1))
:days

julia> Typstry.duration(Dates.Hour(1))
:hours
source
Typstry.escapeFunction
escape(io, n)

Print \ to io n times.

Examples

julia> Typstry.escape(stdout, 2)
\\
source
Typstry.formatFunction
format(::Union{MIME"application/pdf", MIME"image/png", MIME"image/svg+xml"})

Return the image format acronym corresponding to the given MIME.

Examples

julia> Typstry.format(MIME"application/pdf"())
"pdf"

julia> Typstry.format(MIME"image/png"())
"png"

julia> Typstry.format(MIME"image/svg+xml"())
"svg"
source