Internals

This reference documents non-public 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

Strings

Typstry.StringsModule
Strings

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
source
Typstry.Strings.backticksFunction
backticks(io)

Return to io[:backticks]::Int.

Examples

julia> Typstry.Strings.backticks(IOContext(stdout, :backticks => 3))
3
source
Typstry.Strings.blockFunction
block(io)

Return io[:block]::Bool.

Examples

julia> Typstry.Strings.block(IOContext(stdout, :block => true))
true
source
Typstry.Strings.code_modeFunction
code_mode(io)

Print the number sign, unless mode(io) == code.

See also Mode and mode.

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))
#
source
Typstry.Strings.depthFunction
depth(io)

Return io[:depth]::Int.

Examples

julia> Typstry.Strings.depth(IOContext(stdout, :depth => 0))
0
source
Typstry.Strings.encloseFunction
enclose(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 $
source
Typstry.Strings.join_withFunction
join_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
source
Typstry.Strings.math_padFunction
math_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))
"\$"
source
Typstry.Strings.maybe_wrapFunction
maybe_wrap(::Any)

Wrap the value in Typst unless it is a TypstString or TypstText.

Examples

julia> Typstry.Strings.maybe_wrap(1)
Typst{Int64}(1)

julia> Typstry.Strings.maybe_wrap(TypstString(1))
typst"$1$"

julia> Typstry.Strings.maybe_wrap(TypstText(1))
TypstText{Int64}(1)
source
Typstry.Strings.modeFunction
mode(io)

Return io[:mode]::Mode.

See also Mode.

Examples

julia> Typstry.Strings.mode(IOContext(stdout, :mode => code))
code::Mode = 0
source
Typstry.Strings.parenthesizeFunction
parenthesize(io)

Return io[:parenthesize]::Bool.

Examples

julia> Typstry.Strings.parenthesize(IOContext(stdout, :parenthesize => true))
true
source
Typstry.Strings.show_parametersFunction
show_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: "(",
source

Dates.jl

Info

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

Typstry.Strings.durationFunction
duration(::Dates.Period)

Examples

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

julia> Typstry.Strings.duration(Dates.Hour(1))
:hours
source
Typstry.Strings.datesFunction
dates(::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"),))
source

Commands

Typstry.CommandsModule
Commands

A custom command corresponding to the Typst compiler and its implementation of the Cmd interface.

Examples

julia> Typstry.Commands
Typstry.Commands
source
Typstry.Commands.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.Commands.format(MIME"application/pdf"())
"pdf"

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

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