diff --git a/development/.documenter-siteinfo.json b/development/.documenter-siteinfo.json index 1db31fa..6e391fb 100644 --- a/development/.documenter-siteinfo.json +++ b/development/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-06T21:48:01","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-06T22:01:41","documenter_version":"1.5.0"}} \ No newline at end of file diff --git a/development/guides/interoperability/index.html b/development/guides/interoperability/index.html index a39164f..063a210 100644 --- a/development/guides/interoperability/index.html +++ b/development/guides/interoperability/index.html @@ -8,7 +8,7 @@
julia> using TypstJlyfish
julia> TypstJlyfish.compile("typst_jlyfish.typ"; evaluation_file = "typst_jlyfish.json", typst_compile_args = "--format=svg" - ) Activating new project at `/tmp/jlyfish-evalcUtkzS` + ) Activating new project at `/tmp/jlyfish-evallkkaKU` [ Info: Output written to file typst_jlyfish.json downloading @preview/jlyfish:0.1.0 2.7 KiB / 2.7 KiB (100 %) 2.7 KiB/s in 0s ETA: 0s @@ -20,9 +20,9 @@ Updating registry at `~/.julia/registries/General.toml` Resolving package versions... Installed Typstry ─ v0.2.0 - Updating `/tmp/jlyfish-evalcUtkzS/Project.toml` + Updating `/tmp/jlyfish-evallkkaKU/Project.toml` [f0ed7684] + Typstry v0.2.0 - Updating `/tmp/jlyfish-evalcUtkzS/Manifest.toml` + Updating `/tmp/jlyfish-evallkkaKU/Manifest.toml` [692b3bcd] + JLLWrappers v1.5.0 [aea7be01] + PrecompileTools v1.2.1 [21216c6a] + Preferences v1.4.3 @@ -42,4 +42,4 @@ [ Info: Evaluating `using Typstry; typst"$1 / x$"` ... [ Info: Output written to file typst_jlyfish.json [ Info: Compiling document... -[ Info: Done.

TypstJlyfish.jl

+[ Info: Done.

TypstJlyfish.jl

diff --git a/development/guides/the_julia_to_typst_interface/index.html b/development/guides/the_julia_to_typst_interface/index.html index 0fbca93..3ce503f 100644 --- a/development/guides/the_julia_to_typst_interface/index.html +++ b/development/guides/the_julia_to_typst_interface/index.html @@ -66,4 +66,4 @@ range(0, 7, step: 2) julia> println(TypstString(0:2.0:6; mode = code)) -(0.0, 2.0, 4.0, 6.0) +(0.0, 2.0, 4.0, 6.0) diff --git a/development/guides/typst_formatting_examples/index.html b/development/guides/typst_formatting_examples/index.html index b136596..b9db1ea 100644 --- a/development/guides/typst_formatting_examples/index.html +++ b/development/guides/typst_formatting_examples/index.html @@ -1,2 +1,2 @@ -Typst Formatting Examples · Typstry.jl

Typst Formatting Examples

This guide illustrates Typst formatting for supported types.

These Typst documents were generated from Julia using show with the text/typst MIME type and compiled using a TypstCommand. Each row corresponds to a method of show_typst. The Typst columns contain the code, markup, and math syntactical Modes. Each mode contains two columns, where the first is the Typst source text and the second is how that text is rendered in a compiled document. Sequential documents correspond to Package Extensions.

Tip

Open these images in a new tab or another viewer.

Typstry.jl examples LaTeXStrings.jl examples Markdown.jl examples

+Typst Formatting Examples · Typstry.jl

Typst Formatting Examples

This guide illustrates Typst formatting for supported types.

These Typst documents were generated from Julia using show with the text/typst MIME type and compiled using a TypstCommand. Each row corresponds to a method of show_typst. The Typst columns contain the code, markup, and math syntactical Modes. Each mode contains two columns, where the first is the Typst source text and the second is how that text is rendered in a compiled document. Sequential documents correspond to Package Extensions.

Tip

Open these images in a new tab or another viewer.

Typstry.jl examples LaTeXStrings.jl examples Markdown.jl examples

diff --git a/development/index.html b/development/index.html index ed19c32..3ced315 100644 --- a/development/index.html +++ b/development/index.html @@ -24,5 +24,5 @@ julia> TypstCommand(["help"]) typst`help` -julia> addenv(typst`compile input.typ output.pdf`, "TYPST_FONT_PATHS" => julia_mono) -typst`compile input.typ output.pdf`

Features

Strings

Commands

Planned

Similar Packages

Typst

LaTeX

+julia> typst`compile input.typ output.pdf` +typst`compile input.typ output.pdf`

Features

Strings

Commands

Planned

Similar Packages

Typst

LaTeX

diff --git a/development/references/commands/index.html b/development/references/commands/index.html index be82800..680448b 100644 --- a/development/references/commands/index.html +++ b/development/references/commands/index.html @@ -4,45 +4,45 @@ typst`help` julia> TypstCommand(help; ignorestatus = true) -typst`help`source
Typstry.Commands.TypstErrorType
TypstError <: Exception
-TypstError(::TypstCommand)

An Exception indicating a failure to run a TypstCommand.

source
Typstry.Commands.@typst_cmdMacro
@typst_cmd(s)
+typst`help`
source
Typstry.Commands.TypstErrorType
TypstError <: Exception
+TypstError(::TypstCommand)

An Exception indicating a failure to run a TypstCommand.

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.julia_monoConstant
julia_mono

An constant artifact containing the JuliaMono typeface.

Use with a TypstCommand and one of addenv, setenv, or the font-path Typst command-line option.

source
Typstry.Commands.preambleConstant
preamble

A constant used at the beginning of Typst source files generated by show(::IO, ::Union{MIME"application/pdf", MIME"image/png", MIME"image/svg+xml"}, ::TypstString).

Examples

julia> println(Typstry.Commands.preamble)
+typst`compile input.typ output.typ`
source
Typstry.Commands.julia_monoConstant
julia_mono

An constant artifact containing the JuliaMono typeface.

Use with a TypstCommand and one of addenv, setenv, or the font-path Typst command-line option.

source
Typstry.Commands.preambleConstant
preamble

A constant used at the beginning of Typst source files generated by show(::IO, ::Union{MIME"application/pdf", MIME"image/png", MIME"image/svg+xml"}, ::TypstString).

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;
+#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 Typst source text with the preamble and formatted value. Then it is compiled into 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.

See also preamble.

Examples

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

Base

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

See also TypstCommand.

Examples

julia> help = typst`help`
+context...)

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

This first generates the input file containing Typst source text with the preamble and formatted value. Then it is compiled into 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.

See also preamble.

Examples

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

Base

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

See also TypstCommand.

Examples

julia> help = typst`help`
 typst`help`
 
 julia> help == help
 true
 
 julia> help == TypstCommand(help; ignorestatus = true)
-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.detachFunction
detach(::TypstCommand)

See also TypstCommand.

Examples

julia> detach(typst`help`)
-typst`help`
source
Base.eltypeFunction
eltype(::Type{TypstCommand})

See also TypstCommand.

Examples

julia> eltype(TypstCommand)
-String
source
Base.firstindexFunction
firstindex(::TypstCommand)

See also TypstCommand.

Examples

julia> firstindex(typst`help`)
-1
source
Base.getindexFunction
getindex(::TypstCommand, i)

See also TypstCommand.

Examples

julia> typst`help`[2]
-"help"
source
Base.hashFunction
hash(::TypstCommand, ::UInt)

See also TypstCommand.

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)
+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.detachFunction
detach(::TypstCommand)

See also TypstCommand.

Examples

julia> detach(typst`help`)
+typst`help`
source
Base.eltypeFunction
eltype(::Type{TypstCommand})

See also TypstCommand.

Examples

julia> eltype(TypstCommand)
+String
source
Base.firstindexFunction
firstindex(::TypstCommand)

See also TypstCommand.

Examples

julia> firstindex(typst`help`)
+1
source
Base.getindexFunction
getindex(::TypstCommand, i)

See also TypstCommand.

Examples

julia> typst`help`[2]
+"help"
source
Base.hashFunction
hash(::TypstCommand, ::UInt)

See also TypstCommand.

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`)
+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.lastindexFunction
lastindex(::TypstCommand)

See also TypstCommand.

Examples

julia> lastindex(typst`help`)
-2
source
Base.lengthFunction
length(::TypstCommand)

See also TypstCommand.

Examples

julia> length(typst`help`)
-2
source
Base.runFunction
run(::TypstCommand, args...; kwargs...)

See also TypstCommand.

Info

If the Typst compiler throws an error, it will be printed to stderr. Then, a Julia TypstError will be thrown unless the ignorestatus flag is set.

source
Base.setcpuaffinityFunction
setcpuaffinity(::TypstCommand, cpus)

See also TypstCommand.

Compat

Requires at least Julia v0.8.

Examples

julia> setcpuaffinity(typst`help`, nothing)
-typst`help`
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{
+ 2
source
Base.lastindexFunction
lastindex(::TypstCommand)

See also TypstCommand.

Examples

julia> lastindex(typst`help`)
+2
source
Base.lengthFunction
length(::TypstCommand)

See also TypstCommand.

Examples

julia> length(typst`help`)
+2
source
Base.runFunction
run(::TypstCommand, args...; kwargs...)

See also TypstCommand.

Info

If the Typst compiler throws an error, it will be printed to stderr. Then, a Julia TypstError will be thrown unless the ignorestatus flag is set.

source
Base.setcpuaffinityFunction
setcpuaffinity(::TypstCommand, cpus)

See also TypstCommand.

Compat

Requires at least Julia v0.8.

Examples

julia> setcpuaffinity(typst`help`, nothing)
+typst`help`
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 Typsts, TypstStrings, and TypstTexts.

source
Base.showerrorFunction
showerror(::IO, ::TypstError)

Print a TypstError when failing to run a TypstCommand.

Examples

julia> showerror(stdout, TypstError(typst``))
-TypstError: failed to `run` a `TypstCommand(String[])`
source
+}, ::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 Typsts, TypstStrings, and TypstTexts.

source
Base.showerrorFunction
showerror(::IO, ::TypstError)

Print a TypstError when failing to run a TypstCommand.

Examples

julia> showerror(stdout, TypstError(typst``))
+TypstError: failed to `run` a `TypstCommand(String[])`
source
diff --git a/development/references/internals/index.html b/development/references/internals/index.html index a7c6026..a1fa217 100644 --- a/development/references/internals/index.html +++ b/development/references/internals/index.html @@ -1,55 +1,55 @@ -Internals · Typstry.jl

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))
+Internals · Typstry.jl

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))
+#
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.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
Typstry.Strings.static_parseFunction
static_parse(args...; filename, kwargs...)

Call Meta.parse with the filename if it is supported in the current Julia version (at least v1.10).

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(::Union{Dates.Day, Dates.Hour, Dates.Minute, Dates.Second, Dates.Week})

Examples

julia> Typstry.Strings.duration(Dates.Day(1))
+  delim: "(",
source
Typstry.Strings.static_parseFunction
static_parse(args...; filename, kwargs...)

Call Meta.parse with the filename if it is supported in the current Julia version (at least v1.10).

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(::Union{Dates.Day, Dates.Hour, Dates.Minute, Dates.Second, Dates.Week})

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.Day, Dates.Hour,
     Dates.Minute, Dates.Second, Dates.Time, Dates.Week
 })

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"())
+("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
+"svg"
source
diff --git a/development/references/package_extensions/index.html b/development/references/package_extensions/index.html index f8c9a8e..7ab93dd 100644 --- a/development/references/package_extensions/index.html +++ b/development/references/package_extensions/index.html @@ -1,2 +1,2 @@ -Package Extensions · Typstry.jl

Package Extensions

This reference documents the lazily-loaded implementations of show_typst for types defined in external packages.

LaTeXStrings.jl

Typstry.Strings.show_typstMethod
show_typst(io, ::LaTeXString)

Print in Typst format for LaTeXStrings.jl.

TypeSettingsParameters
LaTeXString:block, :depth, :mode, :tab_size
source

Markdown.jl

Typstry.Strings.show_typstMethod
show_typst(io, ::Markdown.MD)

Print in Typst format for Markdown.jl.

TypeSettingsParameters
Markdown.MD:block, :depth, :mode, :tab_size
source
+Package Extensions · Typstry.jl

Package Extensions

This reference documents the lazily-loaded implementations of show_typst for types defined in external packages.

LaTeXStrings.jl

Typstry.Strings.show_typstMethod
show_typst(io, ::LaTeXString)

Print in Typst format for LaTeXStrings.jl.

TypeSettingsParameters
LaTeXString:block, :depth, :mode, :tab_size
source

Markdown.jl

Typstry.Strings.show_typstMethod
show_typst(io, ::Markdown.MD)

Print in Typst format for Markdown.jl.

TypeSettingsParameters
Markdown.MD:block, :depth, :mode, :tab_size
source
diff --git a/development/references/strings/index.html b/development/references/strings/index.html index 2882ed9..4510dc1 100644 --- a/development/references/strings/index.html +++ b/development/references/strings/index.html @@ -3,22 +3,22 @@ Enum Mode: code = 0 markup = 1 -math = 2source
Typstry.Strings.TypstType
Typst{T}
+math = 2
source
Typstry.Strings.TypstType
Typst{T}
 Typst(::T)

A wrapper used to pass values to show(::IO, ::MIME"text/typst", ::Typst).

Examples

julia> Typst(1)
 Typst{Int64}(1)
 
 julia> Typst("a")
-Typst{String}("a")
source
Typstry.Strings.TypstStringType
TypstString <: AbstractString
+Typst{String}("a")
source
Typstry.Strings.TypstStringType
TypstString <: AbstractString
 TypstString(::Any; context...)

Convert the value to a Typst formatted string.

Optional Julia settings and Typst parameters are passed to show(::IO, ::MIME"text/typst", ::Typst) in an IOContext. See also show_typst for a list of supported types.

Info

This type implements the String interface. However, the interface is unspecified, which may result in unexpected behavior.

Examples

julia> TypstString(1)
 typst"$1$"
 
 julia> TypstString(1 + 2im; mode = math)
-typst"(1 + 2i)"
source
Typstry.Strings.TypstTextType
TypstText{T}
+typst"(1 + 2i)"
source
Typstry.Strings.TypstTextType
TypstText{T}
 TypstText(::Any)

A wrapper whose show_typst method uses print.

Info

This may be used to insert control characters into a TypstString. Unescaped control characters in TypstStrings may break formatting in some environments, such as the REPL.

Examples

julia> TypstText(1)
 TypstText{Int64}(1)
 
 julia> TypstText("a")
-TypstText{String}("a")
source
Typstry.Strings.@typst_strMacro
@typst_str(s)
+TypstText{String}("a")
source
Typstry.Strings.@typst_strMacro
@typst_str(s)
 typst"s"

Construct a TypstString.

Control characters are escaped, except double quotation marks and backslashes in the same manner as @raw_str. Values may be interpolated by calling the TypstString constructor, except using a backslash instead of the type name. Interpolation syntax may be escaped in the same manner as quotation marks.

Tip

Print directly to an IO using show(::IO, ::MIME"text/typst", ::Typst).

See also the performance tip to Avoid string interpolation for I/O.

Examples

julia> x = 1;
 
 julia> typst"$ \(x; mode = math) / \(x + 1; mode = math) $"
@@ -31,32 +31,32 @@
 typst"(1 / 2)"
 
 julia> typst"\\(x)"
-typst"\\(x)"
source
Typstry.Strings.codeConstant
code

A Typst syntactical Mode prefixed by the number sign.

Examples

julia> code
-code::Mode = 0
source
Typstry.Strings.markupConstant
markup

A Typst syntactical Mode at the top-level of source text and enclosed within square brackets.

julia> markup
-markup::Mode = 1
source
Typstry.Strings.mathConstant
math

A Typst syntactical Mode enclosed within dollar signs.

julia> math
-math::Mode = 2
source
Typstry.Strings.contextFunction
context(x)

Provide formatting data for show(::IO, ::MIME"text/typst", ::Typst).

Implement this function for a custom type to specify its custom settings and parameters. Passing a value wrapped in Typst will merge! its custom context with defaults, such that the defaults may be overwritten. To be compatible with merging contexts and constructing an IOContext, methods must return an AbstractDict{Symbol}.

SettingDefaultTypeDescription
:backticks3IntThe number of backticks to enclose raw text markup, which may be increased to disambiguiate nested raw text.
:blockfalseBoolWhen :mode => math, specifies whether the enclosing dollar signs are padded with a space to render the element inline or its own block.
:depth0IntThe current level of nesting within container types to specify the degree of indentation.
:modemarkupModeThe current Typst syntactical context where code follows the number sign, markup is at the top-level and enclosed in square brackets, and math is enclosed in dollar signs.
:parenthesizetrueBoolWhether to enclose some mathematical elements in parentheses to specify their operator precedence and avoid ambiguity.
:tab_size2IntThe number of spaces used by some elements with multi-line Typst formatting, which is repeated for each level of depth
source
Typstry.Strings.show_typstMethod
show_typst(io, x)

Print in Typst format with Julia settings and Typst parameters provided by an IOContext.

Implement this function for a custom type to specify its Typst formatting. A setting is a value used in Julia, whose type varies across settings. A parameter is passed directly to a Typst function and must be a TypstString with the same name as in Typst, except that dashes are replaced with underscores. Some settings, such as block, correspond with a parameter but may be used in Julia.

For additional information on settings and parameters, see also context and the Typst Documentation, respectively.

Info

Some types, particularly containers, may call show(::IO, ::MIME"text/typst", ::Typst) to format a value, which may use additional settings and parameters.

Warning

This function's methods are incomplete. Please file an issue or create a pull-request for missing methods.

TypeSettingsParameters
AbstractArray:block, :depth, :mode, :tab_size:delim, :gap
AbstractChar
AbstractFloat:mode
AbstractMatrix:block, :depth, :mode, :tab_size:augment, :column_gap, :delim, :gap, :row_gap
AbstractString
Bool:mode
Complex{Bool}:block, :mode, :parenthesize
Complex:block, :mode, :parenthesize
Irrational:mode
Nothing:mode
OrdinalRange{<:Integer, <:Integer}:mode
Rational:block, :mode, :parenthesize
Regex:mode
Signed:mode
StepRangeLen{<:Integer, <:Integer, <:Integer}:mode
String:mode
Tuple:block, :depth, :mode, :tab_size:delim, :gap
Typst
TypstString
TypstText:mode
Unsigned:mode
VersionNumber:mode
Docs.HTML:block, :depth, :mode, :tab_size
Docs.Text:mode
Dates.Date:mode, :indent
Dates.DateTime:mode, :indent
Dates.Day:mode, :indent
Dates.Hour:mode, :indent
Dates.Minute:mode, :indent
Dates.Second:mode, :indent
Dates.Time:mode, :indent
Dates.Week:mode, :indent
source

Base

Base.IOBufferType
IOBuffer(::TypstString)

See also TypstString.

Examples

julia> IOBuffer(typst"a")
-IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=1, maxsize=Inf, ptr=1, mark=-1)
source
Base.codeunitFunction
codeunit(::TypstString)
+typst"\\(x)"
source
Typstry.Strings.codeConstant
code

A Typst syntactical Mode prefixed by the number sign.

Examples

julia> code
+code::Mode = 0
source
Typstry.Strings.markupConstant
markup

A Typst syntactical Mode at the top-level of source text and enclosed within square brackets.

julia> markup
+markup::Mode = 1
source
Typstry.Strings.mathConstant
math

A Typst syntactical Mode enclosed within dollar signs.

julia> math
+math::Mode = 2
source
Typstry.Strings.contextFunction
context(x)

Provide formatting data for show(::IO, ::MIME"text/typst", ::Typst).

Implement this function for a custom type to specify its custom settings and parameters. Passing a value wrapped in Typst will merge! its custom context with defaults, such that the defaults may be overwritten. To be compatible with merging contexts and constructing an IOContext, methods must return an AbstractDict{Symbol}.

SettingDefaultTypeDescription
:backticks3IntThe number of backticks to enclose raw text markup, which may be increased to disambiguiate nested raw text.
:blockfalseBoolWhen :mode => math, specifies whether the enclosing dollar signs are padded with a space to render the element inline or its own block.
:depth0IntThe current level of nesting within container types to specify the degree of indentation.
:modemarkupModeThe current Typst syntactical context where code follows the number sign, markup is at the top-level and enclosed in square brackets, and math is enclosed in dollar signs.
:parenthesizetrueBoolWhether to enclose some mathematical elements in parentheses to specify their operator precedence and avoid ambiguity.
:tab_size2IntThe number of spaces used by some elements with multi-line Typst formatting, which is repeated for each level of depth
source
Typstry.Strings.show_typstMethod
show_typst(io, x)

Print in Typst format with Julia settings and Typst parameters provided by an IOContext.

Implement this function for a custom type to specify its Typst formatting. A setting is a value used in Julia, whose type varies across settings. A parameter is passed directly to a Typst function and must be a TypstString with the same name as in Typst, except that dashes are replaced with underscores. Some settings, such as block, correspond with a parameter but may be used in Julia.

For additional information on settings and parameters, see also context and the Typst Documentation, respectively.

Info

Some types, particularly containers, may call show(::IO, ::MIME"text/typst", ::Typst) to format a value, which may use additional settings and parameters.

Warning

This function's methods are incomplete. Please file an issue or create a pull-request for missing methods.

TypeSettingsParameters
AbstractArray:block, :depth, :mode, :tab_size:delim, :gap
AbstractChar
AbstractFloat:mode
AbstractMatrix:block, :depth, :mode, :tab_size:augment, :column_gap, :delim, :gap, :row_gap
AbstractString
Bool:mode
Complex{Bool}:block, :mode, :parenthesize
Complex:block, :mode, :parenthesize
Irrational:mode
Nothing:mode
OrdinalRange{<:Integer, <:Integer}:mode
Rational:block, :mode, :parenthesize
Regex:mode
Signed:mode
StepRangeLen{<:Integer, <:Integer, <:Integer}:mode
String:mode
Tuple:block, :depth, :mode, :tab_size:delim, :gap
Typst
TypstString
TypstText:mode
Unsigned:mode
VersionNumber:mode
Docs.HTML:block, :depth, :mode, :tab_size
Docs.Text:mode
Dates.Date:mode, :indent
Dates.DateTime:mode, :indent
Dates.Day:mode, :indent
Dates.Hour:mode, :indent
Dates.Minute:mode, :indent
Dates.Second:mode, :indent
Dates.Time:mode, :indent
Dates.Week:mode, :indent
source

Base

Base.IOBufferType
IOBuffer(::TypstString)

See also TypstString.

Examples

julia> IOBuffer(typst"a")
+IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=1, maxsize=Inf, ptr=1, mark=-1)
source
Base.codeunitFunction
codeunit(::TypstString)
 codeunit(::TypstString, ::Integer)

See also TypstString.

Examples

julia> codeunit(typst"a")
 UInt8
 
 julia> codeunit(typst"a", 1)
-0x61
source
Base.isvalidFunction
isvalid(::TypstString, ::Integer)

See also TypstString.

Examples

julia> isvalid(typst"a", 1)
-true
source
Base.iterateMethod
iterate(::TypstString, ::Integer)
+0x61
source
Base.isvalidFunction
isvalid(::TypstString, ::Integer)

See also TypstString.

Examples

julia> isvalid(typst"a", 1)
+true
source
Base.iterateMethod
iterate(::TypstString, ::Integer)
 iterate(::TypstString)

See also TypstString.

Examples

julia> iterate(typst"a")
 ('a', 2)
 
 julia> iterate(typst"a", 1)
-('a', 2)
source
Base.ncodeunitsFunction
ncodeunits(::TypstString)

See also TypstString.

Examples

julia> ncodeunits(typst"a")
-1
source
Base.pointerFunction
pointer(::TypstString)

See also TypstString.

source
Base.reprFunction
repr(::MIME, ::TypstString; kwargs...)

See also TypstString.

Info

This method patches incorrect output from the assumption in repr that the parameter is already in the requested MIME type when the MIME type istextmime and the parameter is an AbstractString.

Examples

julia> repr("text/plain", typst"a")
+('a', 2)
source
Base.ncodeunitsFunction
ncodeunits(::TypstString)

See also TypstString.

Examples

julia> ncodeunits(typst"a")
+1
source
Base.pointerFunction
pointer(::TypstString)

See also TypstString.

source
Base.reprFunction
repr(::MIME, ::TypstString; kwargs...)

See also TypstString.

Info

This method patches incorrect output from the assumption in repr that the parameter is already in the requested MIME type when the MIME type istextmime and the parameter is an AbstractString.

Examples

julia> repr("text/plain", typst"a")
 "typst\"a\""
 
 julia> repr("text/typst", typst"a")
-typst"a"
source
Base.showMethod
show(::IO, ::TypstString)

See also TypstString.

Examples

julia> show(stdout, typst"a")
-typst"a"
source
Base.showMethod
show(::IO, ::MIME"text/typst", ::Union{Typst, TypstString, TypstText})

Print the Typst format.

This method provides formatting data to show_typst specified by a default and custom context.

See also TypstString and TypstText.

Examples

julia> show(stdout, "text/typst", typst"a")
+typst"a"
source
Base.showMethod
show(::IO, ::TypstString)

See also TypstString.

Examples

julia> show(stdout, typst"a")
+typst"a"
source
Base.showMethod
show(::IO, ::MIME"text/typst", ::Union{Typst, TypstString, TypstText})

Print the Typst format.

This method provides formatting data to show_typst specified by a default and custom context.

See also TypstString and TypstText.

Examples

julia> show(stdout, "text/typst", typst"a")
 a
 
 julia> show(stdout, "text/typst", Typst("a"))
 "a"
 
 julia> show(stdout, "text/typst", Typst(Text("a")))
-a
source
+asource diff --git a/development/search_index.js b/development/search_index.js index b93bc60..4534286 100644 --- a/development/search_index.js +++ b/development/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"references/internals/#Internals","page":"Internals","title":"Internals","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"This reference documents non-public utilities.","category":"page"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.compile_workload","category":"page"},{"location":"references/internals/#Typstry.compile_workload","page":"Internals","title":"Typstry.compile_workload","text":"compile_workload(examples)\n\nGiven an iterable of value-type pairs, interpolate each value into a @typst_str within a PrecompileTools.@compile_workload block.\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Strings","page":"Internals","title":"Strings","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.Strings\nTypstry.Strings.examples\nTypstry.Strings.typst_mime\nTypstry.Strings.backticks\nTypstry.Strings.block\nTypstry.Strings.code_mode\nTypstry.Strings.depth\nTypstry.Strings.enclose\nTypstry.Strings.indent\nTypstry.Strings.join_with\nTypstry.Strings.math_mode\nTypstry.Strings.math_pad\nTypstry.Strings.maybe_wrap\nTypstry.Strings.mode\nTypstry.Strings.parenthesize\nTypstry.Strings.show_array\nTypstry.Strings.show_parameters\nTypstry.Strings.show_raw\nTypstry.Strings.show_vector\nTypstry.Strings.static_parse","category":"page"},{"location":"references/internals/#Typstry.Strings","page":"Internals","title":"Typstry.Strings","text":"Strings\n\nThe Julia to Typst interface, a custom string corresponding to Typst source text, and its implementation of the String interface.\n\nExamples\n\njulia> Typstry.Strings\nTypstry.Strings\n\n\n\n\n\n","category":"module"},{"location":"references/internals/#Typstry.Strings.examples","page":"Internals","title":"Typstry.Strings.examples","text":"examples\n\nA constant Vector of Julia values and their corresponding Types implemented for show_typst.\n\n\n\n\n\n","category":"constant"},{"location":"references/internals/#Typstry.Strings.typst_mime","page":"Internals","title":"Typstry.Strings.typst_mime","text":"typst_mime\n\nEquivalent to MIME\"text/typst\"().\n\nExamples\n\njulia> Typstry.Strings.typst_mime\nMIME type text/typst\n\n\n\n\n\n","category":"constant"},{"location":"references/internals/#Typstry.Strings.backticks","page":"Internals","title":"Typstry.Strings.backticks","text":"backticks(io)\n\nReturn to io[:backticks]::Int.\n\nExamples\n\njulia> Typstry.Strings.backticks(IOContext(stdout, :backticks => 3))\n3\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.block","page":"Internals","title":"Typstry.Strings.block","text":"block(io)\n\nReturn io[:block]::Bool.\n\nExamples\n\njulia> Typstry.Strings.block(IOContext(stdout, :block => true))\ntrue\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.code_mode","page":"Internals","title":"Typstry.Strings.code_mode","text":"code_mode(io)\n\nPrint the number sign, unless mode(io) == code.\n\nSee also Mode and mode.\n\nExamples\n\njulia> Typstry.Strings.code_mode(IOContext(stdout, :mode => code))\n\njulia> Typstry.Strings.code_mode(IOContext(stdout, :mode => markup))\n#\n\njulia> Typstry.Strings.code_mode(IOContext(stdout, :mode => math))\n#\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.depth","page":"Internals","title":"Typstry.Strings.depth","text":"depth(io)\n\nReturn io[:depth]::Int.\n\nExamples\n\njulia> Typstry.Strings.depth(IOContext(stdout, :depth => 0))\n0\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.enclose","page":"Internals","title":"Typstry.Strings.enclose","text":"enclose(f, io, x, left, right = reverse(left); kwargs...)\n\nCall f(io, x; kwargs...) between printing left and right, respectfully.\n\nExamples\n\njulia> Typstry.Strings.enclose((io, i; x) -> print(io, i, x), stdout, 1, \"\\$ \"; x = \"x\")\n$ 1x $\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.indent","page":"Internals","title":"Typstry.Strings.indent","text":"indent(io)\n\nReturn \" \" ^ io[:tab_size]::Int.\n\nSee also TypstString.\n\nExamples\n\njulia> Typstry.Strings.indent(IOContext(stdout, :tab_size => 2))\n\" \"\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.join_with","page":"Internals","title":"Typstry.Strings.join_with","text":"join_with(f, io, xs, delimeter; kwargs...)\n\nSimilar to join, except printing with f(io, x; kwargs...).\n\nExamples\n\njulia> Typstry.Strings.join_with((io, i; x) -> print(io, -i, x), stdout, 1:4, \", \"; x = \"x\")\n-1x, -2x, -3x, -4x\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.math_mode","page":"Internals","title":"Typstry.Strings.math_mode","text":"math_mode(f, io, x; kwargs...)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.math_pad","page":"Internals","title":"Typstry.Strings.math_pad","text":"math_pad(io)\n\nReturn \"\", \"\\$\", or \"\\$ \" depending on the block and mode settings.\n\nExamples\n\njulia> Typstry.Strings.math_pad(IOContext(stdout, :mode => math))\n\"\"\n\njulia> Typstry.Strings.math_pad(IOContext(stdout, :block => true, :mode => markup))\n\"\\$ \"\n\njulia> Typstry.Strings.math_pad(IOContext(stdout, :block => false, :mode => markup))\n\"\\$\"\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.maybe_wrap","page":"Internals","title":"Typstry.Strings.maybe_wrap","text":"maybe_wrap(::Any)\n\nWrap the value in Typst unless it is a TypstString or TypstText.\n\nExamples\n\njulia> Typstry.Strings.maybe_wrap(1)\nTypst{Int64}(1)\n\njulia> Typstry.Strings.maybe_wrap(TypstString(1))\ntypst\"$1$\"\n\njulia> Typstry.Strings.maybe_wrap(TypstText(1))\nTypstText{Int64}(1)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.mode","page":"Internals","title":"Typstry.Strings.mode","text":"mode(io)\n\nReturn io[:mode]::Mode.\n\nSee also Mode.\n\nExamples\n\njulia> Typstry.Strings.mode(IOContext(stdout, :mode => code))\ncode::Mode = 0\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.parenthesize","page":"Internals","title":"Typstry.Strings.parenthesize","text":"parenthesize(io)\n\nReturn io[:parenthesize]::Bool.\n\nExamples\n\njulia> Typstry.Strings.parenthesize(IOContext(stdout, :parenthesize => true))\ntrue\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_array","page":"Internals","title":"Typstry.Strings.show_array","text":"show_array(io, x)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_parameters","page":"Internals","title":"Typstry.Strings.show_parameters","text":"show_parameters(io, f, keys, final)\n\nExamples\n\njulia> Typstry.Strings.show_parameters(\n IOContext(stdout, :depth => 0, :tab_size => 2, :delim => typst\"\\\"(\\\"\"),\n \"vec\", [:delim, :gap], true)\nvec(\n delim: \"(\",\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_raw","page":"Internals","title":"Typstry.Strings.show_raw","text":"show_raw(f, io, x, language)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_vector","page":"Internals","title":"Typstry.Strings.show_vector","text":"show_vector(io, x)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.static_parse","page":"Internals","title":"Typstry.Strings.static_parse","text":"static_parse(args...; filename, kwargs...)\n\nCall Meta.parse with the filename if it is supported in the current Julia version (at least v1.10).\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Dates.jl","page":"Internals","title":"Dates.jl","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"info: Info\nA Dates.jl package extension would currently print warnings during precompilation. See also the Julia issue #52511","category":"page"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.Strings.date_time\nTypstry.Strings.duration\nTypstry.Strings.dates","category":"page"},{"location":"references/internals/#Typstry.Strings.date_time","page":"Internals","title":"Typstry.Strings.date_time","text":"date_time(::Union{Dates.Date, Dates.Time, Dates.DateTime})\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.duration","page":"Internals","title":"Typstry.Strings.duration","text":"duration(::Union{Dates.Day, Dates.Hour, Dates.Minute, Dates.Second, Dates.Week})\n\nExamples\n\njulia> Typstry.Strings.duration(Dates.Day(1))\n:days\n\njulia> Typstry.Strings.duration(Dates.Hour(1))\n:hours\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.dates","page":"Internals","title":"Typstry.Strings.dates","text":"dates(::Union{\n Dates.Date, Dates.DateTime, Dates.Day, Dates.Hour,\n Dates.Minute, Dates.Second, Dates.Time, Dates.Week\n})\n\nExamples\n\njulia> Typstry.Strings.dates(Dates.Date(1))\n(\"datetime\", (:year, :month, :day), (1, 1, 1))\n\njulia> Typstry.Strings.dates(Dates.Day(1))\n(\"duration\", (:days,), (TypstText{String}(\"1\"),))\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Commands","page":"Internals","title":"Commands","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.Commands\nTypstry.Commands.typst_compiler\nTypstry.Commands.apply\nTypstry.Commands.format","category":"page"},{"location":"references/internals/#Typstry.Commands","page":"Internals","title":"Typstry.Commands","text":"Commands\n\nA custom command corresponding to the Typst compiler and its implementation of the Cmd interface.\n\nExamples\n\njulia> Typstry.Commands\nTypstry.Commands\n\n\n\n\n\n","category":"module"},{"location":"references/internals/#Typstry.Commands.typst_compiler","page":"Internals","title":"Typstry.Commands.typst_compiler","text":"typst_compiler\n\nA constant Cmd that is the Typst compiler given by Typst_jll.jl with no additional parameters.\n\n\n\n\n\n","category":"constant"},{"location":"references/internals/#Typstry.Commands.apply","page":"Internals","title":"Typstry.Commands.apply","text":"apply(f, tc, args...; kwargs...)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Commands.format","page":"Internals","title":"Typstry.Commands.format","text":"format(::Union{MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"})\n\nReturn the image format acronym corresponding to the given MIME.\n\nExamples\n\njulia> Typstry.Commands.format(MIME\"application/pdf\"())\n\"pdf\"\n\njulia> Typstry.Commands.format(MIME\"image/png\"())\n\"png\"\n\njulia> Typstry.Commands.format(MIME\"image/svg+xml\"())\n\"svg\"\n\n\n\n\n\n","category":"function"},{"location":"guides/interoperability/#Interoperability","page":"Interoperability","title":"Interoperability","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"This guide illustrates how to use Typstry.jl in compatible notebooks and packages.","category":"page"},{"location":"guides/interoperability/#Notebooks","page":"Interoperability","title":"Notebooks","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"IJulia.jl, Pluto.jl, and QuartoNotebookRunner.jl each render Typsts and TypstTexts. Pluto.jl and QuartoNotebookRunner.jl also render TypstStrings, whereas IJulia.jl will support them in its next feature release. See also this pull request.","category":"page"},{"location":"guides/interoperability/#Packages","page":"Interoperability","title":"Packages","text":"","category":"section"},{"location":"guides/interoperability/#MakieTeX.jl","page":"Interoperability","title":"MakieTeX.jl","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"note: Note\nThis package re-exports @typst_str and TypstString.","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using Logging: Debug, Warn, disable_logging\ndisable_logging(Warn)","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using CairoMakie, MakieTeX\ndisable_logging(Debug) # hide\nf = Figure(; size = (100, 100));\nLTeX(f[1, 1], TypstDocument(typst\"$1 / x$\"); scale = 5);\nsave(\"makie_tex.svg\", f);","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"(Image: MakieTeX.jl)","category":"page"},{"location":"guides/interoperability/#TypstJlyfish.jl","page":"Interoperability","title":"TypstJlyfish.jl","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using Markdown, Typstry\ns = preamble * typst\"\"\"\n#import \"@preview/jlyfish:0.1.0\": *\n#read-julia-output(json(\"typst_jlyfish.json\"))\n#jl-pkg(\"Typstry\")\n#jl(`using Typstry; typst\"$1 / x$\"`)\n\"\"\"\nwrite(\"typst_jlyfish.typ\", s)\nMarkdown.parse(\"`````typst\\n\" * s * \"\\n`````\")","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using TypstJlyfish\nTypstJlyfish.compile(\"typst_jlyfish.typ\";\n evaluation_file = \"typst_jlyfish.json\",\n typst_compile_args = \"--format=svg\"\n)","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"(Image: TypstJlyfish.jl)","category":"page"},{"location":"guides/the_julia_to_typst_interface/#The-Julia-to-Typst-Interface","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"This guide illustrates how to implement Typst formatting for custom types.","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Setup","page":"The Julia to Typst Interface","title":"Setup","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> import Base: show\n\njulia> import Typstry: context, show_typst\n\njulia> using Typstry","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Implementation","page":"The Julia to Typst Interface","title":"Implementation","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Consider this custom type.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> struct Reciprocal{N <: Number}\n n::N\n end","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Implement a show_typst method to specify its Typst formatting. Remember to Annotate values taken from untyped locations.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> show_typst(io, r::Reciprocal) =\n if io[:mode]::Mode == markup\n print(io, \"#let reciprocal(n) = \\$1 / #n\\$\")\n else\n print(io, \"reciprocal(\")\n show(io, MIME\"text/typst\"(), Typst(round(r.n; digits = io[:digits]::Int)))\n print(io, \")\")\n end;","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Although custom formatting may be handled in show_typst with get(io, key, default), this may be repetitive when specifying defaults for multiple methods. There is also no way to tell if the value has been specified by the user or if it is a default. Instead, implement a custom context which overrides default, but not user specifications.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> context(::Reciprocal) = Dict(:digits => 2);","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Those two methods are a complete implementation of the Julia to Typst interface. The following method is optional:","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> show(io::IO, m::MIME\"text/typst\", r::Reciprocal) = show(io, m, Typst(r));","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Now, a Reciprocal is fully supported by Typstry.jl.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> r = Reciprocal(π);\n\njulia> println(TypstString(r))\n#let reciprocal(n) = $1 / #n$\n\njulia> println(TypstString(r; mode = math))\nreciprocal(3.14)\n\njulia> println(TypstString(r; mode = math, digits = 4))\nreciprocal(3.1416)","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Guidelines","page":"The Julia to Typst Interface","title":"Guidelines","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"While implementing the interface only requires two methods, it may be more challenging to determine how a Julia value should be represented in a Typst source file and its corresponding compiled document. Julia and Typst are distinct languages that differ in both syntax and semantics, so there may be multiple meaningful formats to choose from.","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Make-the-obvious-choice,-if-available","page":"The Julia to Typst Interface","title":"Make the obvious choice, if available","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"There is a clear correspondence between these Julia and Typst values","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(1))\n$1$\n\njulia> println(TypstString(nothing))\n#none\n\njulia> println(TypstString(r\"[a-z]\"))\n#regex(\"[a-z]\")","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Choose-the-most-semantically-rich-representation","page":"The Julia to Typst Interface","title":"Choose the most semantically rich representation","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"This may vary across Modes and domains\nSome modes may not have a meaningful representation, and should be formatted into a mode that does\nBoth Julia and Typst support Unicode characters, except unknown variables in Typst's code mode","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(π; mode = code))\n3.141592653589793\n\njulia> println(TypstString(π; mode = math))\nπ\n\njulia> println(TypstString(π; mode = markup))\n$π$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Consider-both-the-Typst-source-text-and-compiled-document-formatting","page":"The Julia to Typst Interface","title":"Consider both the Typst source text and compiled document formatting","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"A Docs.Text is documented to \"render [its value] as plain text\", and therefore corresponds to text in a rendered Typst document\nA TypstString represents Typst source text, and is printed directly","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(text\"[\\\"a\\\"]\"))\n[\"a\"]\n\njulia> println(TypstString(typst\"[\\\"a\\\"]\"))\n[\"a\"]","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Try-to-generate-valid-Typst-source-text","page":"The Julia to Typst Interface","title":"Try to generate valid Typst source text","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"A TypstString represents Typst source text, which may be invalid\nA UnitRange{Int} is formatted differently for each Mode, but is always valid","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(1:4; mode = code))\nrange(1, 5)\n\njulia> println(TypstString(1:4; mode = math))\nvec(\n 1, 2, 3, 4\n)\n\njulia> println(TypstString(1:4; mode = markup))\n$vec(\n 1, 2, 3, 4\n)$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Test-for-edge-cases","page":"The Julia to Typst Interface","title":"Test for edge cases","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"#1 / 2 is valid Typst source text, but is parsed partially in code mode as (#1) / 2\n1 / 2 may be ambiguous in a math mode expression\n$1 / 2$ is not ambiguous in markup mode","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(1 // 2; mode = code))\n(1 / 2)\n\njulia> println(TypstString(1 // 2; mode = math))\n(1 / 2)\n\njulia> println(TypstString(1 // 2; mode = markup))\n$1 / 2$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Format-values-in-containers-using-show-with-the-text/typst-MIME-type","page":"The Julia to Typst Interface","title":"Format values in containers using show with the text/typst MIME type","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Values may require some of their context\nThe AbstractVector method changes its Mode to math and increments its depth","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString([true, 1, Any[1.2, 1 // 2]]))\n$vec(\n \"true\", 1, vec(\n 1.2, 1 / 2\n )\n)$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Check-parametric-and-abstract-types","page":"The Julia to Typst Interface","title":"Check parametric and abstract types","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Related Julia types may not be representable in the same Typst format","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(0:2:6; mode = code))\nrange(0, 7, step: 2)\n\njulia> println(TypstString(0:2.0:6; mode = code))\n(0.0, 2.0, 4.0, 6.0)","category":"page"},{"location":"references/strings/#Strings","page":"Strings","title":"Strings","text":"","category":"section"},{"location":"references/strings/","page":"Strings","title":"Strings","text":"using Markdown, Typstry\nMarkdown.parse(\"This reference documents \" * lowercasefirst(split(string(@doc Typstry.Strings), \"\\n\")[5]))","category":"page"},{"location":"references/strings/#Typstry","page":"Strings","title":"Typstry","text":"","category":"section"},{"location":"references/strings/","page":"Strings","title":"Strings","text":"Mode\nTypst\nTypstString\nTypstText\n@typst_str\ncode\nmarkup\nmath\ncontext\nshow_typst(::Any, ::AbstractChar)","category":"page"},{"location":"references/strings/#Typstry.Strings.Mode","page":"Strings","title":"Typstry.Strings.Mode","text":"Mode\n\nAn Enumerated type used to specify that the current Typst syntactical context is code, markup, or math.\n\nExamples\n\njulia> Mode\nEnum Mode:\ncode = 0\nmarkup = 1\nmath = 2\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.Typst","page":"Strings","title":"Typstry.Strings.Typst","text":"Typst{T}\nTypst(::T)\n\nA wrapper used to pass values to show(::IO, ::MIME\"text/typst\", ::Typst).\n\nExamples\n\njulia> Typst(1)\nTypst{Int64}(1)\n\njulia> Typst(\"a\")\nTypst{String}(\"a\")\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.TypstString","page":"Strings","title":"Typstry.Strings.TypstString","text":"TypstString <: AbstractString\nTypstString(::Any; context...)\n\nConvert the value to a Typst formatted string.\n\nOptional Julia settings and Typst parameters are passed to show(::IO, ::MIME\"text/typst\", ::Typst) in an IOContext. See also show_typst for a list of supported types.\n\ninfo: Info\nThis type implements the String interface. However, the interface is unspecified, which may result in unexpected behavior.\n\nExamples\n\njulia> TypstString(1)\ntypst\"$1$\"\n\njulia> TypstString(1 + 2im; mode = math)\ntypst\"(1 + 2i)\"\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.TypstText","page":"Strings","title":"Typstry.Strings.TypstText","text":"TypstText{T}\nTypstText(::Any)\n\nA wrapper whose show_typst method uses print.\n\ninfo: Info\nThis may be used to insert control characters into a TypstString. Unescaped control characters in TypstStrings may break formatting in some environments, such as the REPL.\n\nExamples\n\njulia> TypstText(1)\nTypstText{Int64}(1)\n\njulia> TypstText(\"a\")\nTypstText{String}(\"a\")\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.@typst_str","page":"Strings","title":"Typstry.Strings.@typst_str","text":"@typst_str(s)\ntypst\"s\"\n\nConstruct a TypstString.\n\nControl characters are escaped, except double quotation marks and backslashes in the same manner as @raw_str. Values may be interpolated by calling the TypstString constructor, except using a backslash instead of the type name. Interpolation syntax may be escaped in the same manner as quotation marks.\n\ntip: Tip\nPrint directly to an IO using show(::IO, ::MIME\"text/typst\", ::Typst).See also the performance tip to Avoid string interpolation for I/O.\n\nExamples\n\njulia> x = 1;\n\njulia> typst\"$ \\(x; mode = math) / \\(x + 1; mode = math) $\"\ntypst\"$ 1 / 2 $\"\n\njulia> typst\"\\(x//2)\"\ntypst\"$1 / 2$\"\n\njulia> typst\"\\(x // 2; mode = math)\"\ntypst\"(1 / 2)\"\n\njulia> typst\"\\\\(x)\"\ntypst\"\\\\(x)\"\n\n\n\n\n\n","category":"macro"},{"location":"references/strings/#Typstry.Strings.code","page":"Strings","title":"Typstry.Strings.code","text":"code\n\nA Typst syntactical Mode prefixed by the number sign.\n\nExamples\n\njulia> code\ncode::Mode = 0\n\n\n\n\n\n","category":"constant"},{"location":"references/strings/#Typstry.Strings.markup","page":"Strings","title":"Typstry.Strings.markup","text":"markup\n\nA Typst syntactical Mode at the top-level of source text and enclosed within square brackets.\n\njulia> markup\nmarkup::Mode = 1\n\n\n\n\n\n","category":"constant"},{"location":"references/strings/#Typstry.Strings.math","page":"Strings","title":"Typstry.Strings.math","text":"math\n\nA Typst syntactical Mode enclosed within dollar signs.\n\njulia> math\nmath::Mode = 2\n\n\n\n\n\n","category":"constant"},{"location":"references/strings/#Typstry.Strings.context","page":"Strings","title":"Typstry.Strings.context","text":"context(x)\n\nProvide formatting data for show(::IO, ::MIME\"text/typst\", ::Typst).\n\nImplement this function for a custom type to specify its custom settings and parameters. Passing a value wrapped in Typst will merge! its custom context with defaults, such that the defaults may be overwritten. To be compatible with merging contexts and constructing an IOContext, methods must return an AbstractDict{Symbol}.\n\nSetting Default Type Description\n:backticks 3 Int The number of backticks to enclose raw text markup, which may be increased to disambiguiate nested raw text.\n:block false Bool When :mode => math, specifies whether the enclosing dollar signs are padded with a space to render the element inline or its own block.\n:depth 0 Int The current level of nesting within container types to specify the degree of indentation.\n:mode markup Mode The current Typst syntactical context where code follows the number sign, markup is at the top-level and enclosed in square brackets, and math is enclosed in dollar signs.\n:parenthesize true Bool Whether to enclose some mathematical elements in parentheses to specify their operator precedence and avoid ambiguity.\n:tab_size 2 Int The number of spaces used by some elements with multi-line Typst formatting, which is repeated for each level of depth\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Typstry.Strings.show_typst-Tuple{Any, AbstractChar}","page":"Strings","title":"Typstry.Strings.show_typst","text":"show_typst(io, x)\n\nPrint in Typst format with Julia settings and Typst parameters provided by an IOContext.\n\nImplement this function for a custom type to specify its Typst formatting. A setting is a value used in Julia, whose type varies across settings. A parameter is passed directly to a Typst function and must be a TypstString with the same name as in Typst, except that dashes are replaced with underscores. Some settings, such as block, correspond with a parameter but may be used in Julia.\n\nFor additional information on settings and parameters, see also context and the Typst Documentation, respectively.\n\ninfo: Info\nSome types, particularly containers, may call show(::IO, ::MIME\"text/typst\", ::Typst) to format a value, which may use additional settings and parameters.\n\nwarning: Warning\nThis function's methods are incomplete. Please file an issue or create a pull-request for missing methods.\n\nType Settings Parameters\nAbstractArray :block, :depth, :mode, :tab_size :delim, :gap\nAbstractChar \nAbstractFloat :mode \nAbstractMatrix :block, :depth, :mode, :tab_size :augment, :column_gap, :delim, :gap, :row_gap\nAbstractString \nBool :mode \nComplex{Bool} :block, :mode, :parenthesize \nComplex :block, :mode, :parenthesize \nIrrational :mode \nNothing :mode \nOrdinalRange{<:Integer, <:Integer} :mode \nRational :block, :mode, :parenthesize \nRegex :mode \nSigned :mode \nStepRangeLen{<:Integer, <:Integer, <:Integer} :mode \nString :mode \nTuple :block, :depth, :mode, :tab_size :delim, :gap\nTypst \nTypstString \nTypstText :mode \nUnsigned :mode \nVersionNumber :mode \nDocs.HTML :block, :depth, :mode, :tab_size \nDocs.Text :mode \nDates.Date :mode, :indent \nDates.DateTime :mode, :indent \nDates.Day :mode, :indent \nDates.Hour :mode, :indent \nDates.Minute :mode, :indent \nDates.Second :mode, :indent \nDates.Time :mode, :indent \nDates.Week :mode, :indent \n\n\n\n\n\n","category":"method"},{"location":"references/strings/#Base","page":"Strings","title":"Base","text":"","category":"section"},{"location":"references/strings/","page":"Strings","title":"Strings","text":"IOBuffer\ncodeunit\nisvalid\niterate(::TypstString)\nncodeunits\npointer\nrepr\nshow(::IO, ::TypstString)\nshow(::IO, ::MIME\"text/typst\", ::Typst)","category":"page"},{"location":"references/strings/#Base.IOBuffer","page":"Strings","title":"Base.IOBuffer","text":"IOBuffer(::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> IOBuffer(typst\"a\")\nIOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=1, maxsize=Inf, ptr=1, mark=-1)\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Base.codeunit","page":"Strings","title":"Base.codeunit","text":"codeunit(::TypstString)\ncodeunit(::TypstString, ::Integer)\n\nSee also TypstString.\n\nExamples\n\njulia> codeunit(typst\"a\")\nUInt8\n\njulia> codeunit(typst\"a\", 1)\n0x61\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.isvalid","page":"Strings","title":"Base.isvalid","text":"isvalid(::TypstString, ::Integer)\n\nSee also TypstString.\n\nExamples\n\njulia> isvalid(typst\"a\", 1)\ntrue\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.iterate-Tuple{TypstString}","page":"Strings","title":"Base.iterate","text":"iterate(::TypstString, ::Integer)\niterate(::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> iterate(typst\"a\")\n('a', 2)\n\njulia> iterate(typst\"a\", 1)\n('a', 2)\n\n\n\n\n\n","category":"method"},{"location":"references/strings/#Base.ncodeunits","page":"Strings","title":"Base.ncodeunits","text":"ncodeunits(::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> ncodeunits(typst\"a\")\n1\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.pointer","page":"Strings","title":"Base.pointer","text":"pointer(::TypstString)\n\nSee also TypstString.\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.repr","page":"Strings","title":"Base.repr","text":"repr(::MIME, ::TypstString; kwargs...)\n\nSee also TypstString.\n\ninfo: Info\nThis method patches incorrect output from the assumption in repr that the parameter is already in the requested MIME type when the MIME type istextmime and the parameter is an AbstractString.\n\nExamples\n\njulia> repr(\"text/plain\", typst\"a\")\n\"typst\\\"a\\\"\"\n\njulia> repr(\"text/typst\", typst\"a\")\ntypst\"a\"\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.show-Tuple{IO, TypstString}","page":"Strings","title":"Base.show","text":"show(::IO, ::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> show(stdout, typst\"a\")\ntypst\"a\"\n\n\n\n\n\n","category":"method"},{"location":"references/strings/#Base.show-Tuple{IO, MIME{Symbol(\"text/typst\")}, Typst}","page":"Strings","title":"Base.show","text":"show(::IO, ::MIME\"text/typst\", ::Union{Typst, TypstString, TypstText})\n\nPrint the Typst format.\n\nThis method provides formatting data to show_typst specified by a default and custom context.\n\nSee also TypstString and TypstText.\n\nExamples\n\njulia> show(stdout, \"text/typst\", typst\"a\")\na\n\njulia> show(stdout, \"text/typst\", Typst(\"a\"))\n\"a\"\n\njulia> show(stdout, \"text/typst\", Typst(Text(\"a\")))\na\n\n\n\n\n\n","category":"method"},{"location":"references/package_extensions/#Package-Extensions","page":"Package Extensions","title":"Package Extensions","text":"","category":"section"},{"location":"references/package_extensions/","page":"Package Extensions","title":"Package Extensions","text":"This reference documents the lazily-loaded implementations of show_typst for types defined in external packages.","category":"page"},{"location":"references/package_extensions/#LaTeXStrings.jl","page":"Package Extensions","title":"LaTeXStrings.jl","text":"","category":"section"},{"location":"references/package_extensions/","page":"Package Extensions","title":"Package Extensions","text":"show_typst(::Any, ::LaTeXStrings.LaTeXString)","category":"page"},{"location":"references/package_extensions/#Typstry.Strings.show_typst-Tuple{Any, LaTeXString}","page":"Package Extensions","title":"Typstry.Strings.show_typst","text":"show_typst(io, ::LaTeXString)\n\nPrint in Typst format for LaTeXStrings.jl.\n\nType Settings Parameters\nLaTeXString :block, :depth, :mode, :tab_size \n\n\n\n\n\n","category":"method"},{"location":"references/package_extensions/#Markdown.jl","page":"Package Extensions","title":"Markdown.jl","text":"","category":"section"},{"location":"references/package_extensions/","page":"Package Extensions","title":"Package Extensions","text":"show_typst(::Any, ::Markdown.MD)","category":"page"},{"location":"references/package_extensions/#Typstry.Strings.show_typst-Tuple{Any, MD}","page":"Package Extensions","title":"Typstry.Strings.show_typst","text":"show_typst(io, ::Markdown.MD)\n\nPrint in Typst format for Markdown.jl.\n\nType Settings Parameters\nMarkdown.MD :block, :depth, :mode, :tab_size \n\n\n\n\n\n","category":"method"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"DocTestSetup = :(using Typstry)","category":"page"},{"location":"tutorials/getting_started/#Getting-Started","page":"Getting Started","title":"Getting Started","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"This tutorial demonstrates the basic features of Typstry.jl and how to use them.","category":"page"},{"location":"tutorials/getting_started/#Strings","page":"Getting Started","title":"Strings","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Print Julia values in Typst format using show with the text/typst MIME type. This formatting is also used to create a TypstString.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> show(stdout, \"text/typst\", Typst(π))\n$π$\n\njulia> TypstString(π)\ntypst\"$π$\"","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Methods of show_typst are used to specify the Typst formatting, which may use Julia settings and Typst parameters. A setting is a value used in Julia, whereas a parameter is passed directly to a Typst function. Settings each have a default value, whereas the default values of parameters are handled by Typst functions. This context may instead be specified in show using an IOContext and in TypstString using keyword parameters.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> show(IOContext(stdout, :mode => code), \"text/typst\", Typst(π))\n3.141592653589793\n\njulia> TypstString(π; mode = code)\ntypst\"3.141592653589793\"","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Use @typst_str to directly write Typst source text. This also supports formatted interpolation by calling the TypstString constructor.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> typst\"$ \\(pi; mode = math) approx \\(pi; mode = code) $\"\ntypst\"$ π approx 3.141592653589793 $\"","category":"page"},{"location":"tutorials/getting_started/#Commands","page":"Getting Started","title":"Commands","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Use render to easily generate a Typst source file and compile it into a document.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> render(Any[true 1; 1.2 1 // 2]);","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Compile source files by running a TypstCommand created using its constructor or @typst_cmd.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> TypstCommand([\"help\"])\ntypst`help`\n\njulia> run(typst`compile input.typ output.pdf`);","category":"page"},{"location":"references/commands/#Commands","page":"Commands","title":"Commands","text":"","category":"section"},{"location":"references/commands/","page":"Commands","title":"Commands","text":"using Markdown, Typstry\nMarkdown.parse(\"This reference documents \" * lowercasefirst(split(string(@doc Typstry.Commands), \"\\n\")[5]))","category":"page"},{"location":"references/commands/#Typstry","page":"Commands","title":"Typstry","text":"","category":"section"},{"location":"references/commands/","page":"Commands","title":"Commands","text":"TypstCommand\nTypstError\n@typst_cmd\njulia_mono\npreamble\nrender","category":"page"},{"location":"references/commands/#Typstry.Commands.TypstCommand","page":"Commands","title":"Typstry.Commands.TypstCommand","text":"TypstCommand(::Vector{String})\nTypstCommand(::TypstCommand; kwargs...)\n\nThe Typst compiler and its parameters.\n\ninfo: Info\nThis type implements the Cmd interface. However, the interface is unspecified, which may result in unexpected behavior.\n\nExamples\n\njulia> help = TypstCommand([\"help\"])\ntypst`help`\n\njulia> TypstCommand(help; ignorestatus = true)\ntypst`help`\n\n\n\n\n\n","category":"type"},{"location":"references/commands/#Typstry.Commands.TypstError","page":"Commands","title":"Typstry.Commands.TypstError","text":"TypstError <: Exception\nTypstError(::TypstCommand)\n\nAn Exception indicating a failure to run a TypstCommand.\n\n\n\n\n\n","category":"type"},{"location":"references/commands/#Typstry.Commands.@typst_cmd","page":"Commands","title":"Typstry.Commands.@typst_cmd","text":"@typst_cmd(s)\ntypst`s`\n\nConstruct a TypstCommand where each parameter is separated by a space.\n\nThis does not support interpolation; use the constructor instead.\n\nExamples\n\njulia> typst`help`\ntypst`help`\n\njulia> typst`compile input.typ output.typ`\ntypst`compile input.typ output.typ`\n\n\n\n\n\n","category":"macro"},{"location":"references/commands/#Typstry.Commands.julia_mono","page":"Commands","title":"Typstry.Commands.julia_mono","text":"julia_mono\n\nAn constant artifact containing the JuliaMono typeface.\n\nUse with a TypstCommand and one of addenv, setenv, or the font-path Typst command-line option.\n\n\n\n\n\n","category":"constant"},{"location":"references/commands/#Typstry.Commands.preamble","page":"Commands","title":"Typstry.Commands.preamble","text":"preamble\n\nA constant used at the beginning of Typst source files generated by show(::IO, ::Union{MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"}, ::TypstString).\n\nExamples\n\njulia> println(Typstry.Commands.preamble)\n#set page(margin: 1em, height: auto, width: auto, fill: white)\n#set text(16pt, font: \"JuliaMono\")\n\n\n\n\n\n","category":"constant"},{"location":"references/commands/#Typstry.Commands.render","page":"Commands","title":"Typstry.Commands.render","text":"render(x;\n input = \"input.typ\",\n output = \"output.pdf\",\n open = true,\n preamble = Typstry.preamble,\ncontext...)\n\nRender to a document using show(::IO, ::MIME\"text/typst\", ::Typst).\n\nThis first generates the input file containing Typst source text with the preamble and formatted value. Then it is compiled into 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.\n\nSee also preamble.\n\nExamples\n\njulia> render(Any[true 1; 1.2 1 // 2]);\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base","page":"Commands","title":"Base","text":"","category":"section"},{"location":"references/commands/","page":"Commands","title":"Commands","text":"==\naddenv\ndetach\neltype\nfirstindex\ngetindex\nhash\nignorestatus\niterate(::TypstCommand)\nkeys\nlastindex\nlength\nrun\nsetcpuaffinity\nsetenv\nshow(::IO, ::MIME\"text/plain\", ::TypstCommand)\nshow(::IO, ::Union{MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"}, ::Union{Typst, TypstString, TypstText})\nshowerror","category":"page"},{"location":"references/commands/#Base.:==","page":"Commands","title":"Base.:==","text":"==(::TypstCommand, ::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> help = typst`help`\ntypst`help`\n\njulia> help == help\ntrue\n\njulia> help == TypstCommand(help; ignorestatus = true)\nfalse\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.addenv","page":"Commands","title":"Base.addenv","text":"addenv(::TypstCommand, args...; kwargs...)\n\nSee also TypstCommand and julia_mono.\n\nExamples\n\njulia> addenv(typst`compile input.typ output.pdf`, \"TYPST_FONT_PATHS\" => julia_mono)\ntypst`compile input.typ output.pdf`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.detach","page":"Commands","title":"Base.detach","text":"detach(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> detach(typst`help`)\ntypst`help`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.eltype","page":"Commands","title":"Base.eltype","text":"eltype(::Type{TypstCommand})\n\nSee also TypstCommand.\n\nExamples\n\njulia> eltype(TypstCommand)\nString\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.firstindex","page":"Commands","title":"Base.firstindex","text":"firstindex(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> firstindex(typst`help`)\n1\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.getindex","page":"Commands","title":"Base.getindex","text":"getindex(::TypstCommand, i)\n\nSee also TypstCommand.\n\nExamples\n\njulia> typst`help`[2]\n\"help\"\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.hash","page":"Commands","title":"Base.hash","text":"hash(::TypstCommand, ::UInt)\n\nSee also TypstCommand.\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.ignorestatus","page":"Commands","title":"Base.ignorestatus","text":"ignorestatus(::TypstCommand)\n\nReturn a TypstCommand that does not throw a TypstError if the Typst compiler throws an error.\n\nErrors thrown by the Typst compiler are printed to stderr regardless.\n\nExamples\n\njulia> ignorestatus(typst`help`)\ntypst`help`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.iterate-Tuple{TypstCommand}","page":"Commands","title":"Base.iterate","text":"iterate(::TypstCommand)\niterate(::TypstCommand, i)\n\nSee also TypstCommand.\n\nExamples\n\njulia> iterate(typst`help`, 2)\n(\"help\", 3)\n\njulia> iterate(typst`help`, 3)\n\n\n\n\n\n","category":"method"},{"location":"references/commands/#Base.keys","page":"Commands","title":"Base.keys","text":"keys(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> keys(typst`help`)\n2-element LinearIndices{1, Tuple{Base.OneTo{Int64}}}:\n 1\n 2\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.lastindex","page":"Commands","title":"Base.lastindex","text":"lastindex(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> lastindex(typst`help`)\n2\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.length","page":"Commands","title":"Base.length","text":"length(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> length(typst`help`)\n2\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.run","page":"Commands","title":"Base.run","text":"run(::TypstCommand, args...; kwargs...)\n\nSee also TypstCommand.\n\ninfo: Info\nIf the Typst compiler throws an error, it will be printed to stderr. Then, a Julia TypstError will be thrown unless the ignorestatus flag is set.\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.setcpuaffinity","page":"Commands","title":"Base.setcpuaffinity","text":"setcpuaffinity(::TypstCommand, cpus)\n\nSee also TypstCommand.\n\ncompat: Compat\nRequires at least Julia v0.8.\n\nExamples\n\njulia> setcpuaffinity(typst`help`, nothing)\ntypst`help`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.setenv","page":"Commands","title":"Base.setenv","text":"setenv(::TypstCommand, args...; kwargs...)\n\nSee also TypstCommand and julia_mono.\n\nExamples\n\njulia> setenv(typst`compile input.typ output.pdf`, \"TYPST_FONT_PATHS\" => julia_mono)\ntypst`compile input.typ output.pdf`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.show-Tuple{IO, MIME{Symbol(\"text/plain\")}, TypstCommand}","page":"Commands","title":"Base.show","text":"show(::IO, ::MIME\"text/plain\", ::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> show(stdout, \"text/plain\", typst`help`)\ntypst`help`\n\n\n\n\n\n","category":"method"},{"location":"references/commands/#Base.show-Tuple{IO, Union{MIME{Symbol(\"application/pdf\")}, MIME{Symbol(\"image/png\")}, MIME{Symbol(\"image/svg+xml\")}}, Union{TypstString, Typst, TypstText}}","page":"Commands","title":"Base.show","text":"show(::IO, ::Union{\n MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"\n}, ::Union{Typst, TypstString, TypstText})\n\nPrint the Portable Document Format (PDF), Portable Network Graphics (PNG), or Scalable Vector Graphics (SVG) format.\n\nThe preamble keyword parameter used by render may be specified in an IOContext.\n\nEnvironments, such as Pluto.jl notebooks, may use these methods to display Typsts, TypstStrings, and TypstTexts.\n\n\n\n\n\n","category":"method"},{"location":"references/commands/#Base.showerror","page":"Commands","title":"Base.showerror","text":"showerror(::IO, ::TypstError)\n\nPrint a TypstError when failing to run a TypstCommand.\n\nExamples\n\njulia> showerror(stdout, TypstError(typst``))\nTypstError: failed to `run` a `TypstCommand(String[])`\n\n\n\n\n\n","category":"function"},{"location":"","page":"Home","title":"Home","text":"DocTestSetup = :(using Typstry)","category":"page"},{"location":"#Home","page":"Home","title":"Home","text":"","category":"section"},{"location":"#Introduction","page":"Home","title":"Introduction","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Typstry.jl is the interface to convert the computational power of Julia into beautifully formatted Typst documents.","category":"page"},{"location":"#What-is-Typst?","page":"Home","title":"What is Typst?","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Typst is an open-source and relatively new typesetting system (written in Rust 🦀🚀), designed to improve upon the performance and usability of LaTeX. See also the Typst repository and documentation for examples and how to get started.","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"julia> using Pkg: add\n\njulia> add(\"Typstry\")\n\njulia> using Typstry","category":"page"},{"location":"#Showcase","page":"Home","title":"Showcase","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"julia> show_typst(IOContext(stdout, :mode => code), true)\ntrue\n\njulia> show(stdout, \"text/typst\", Typst([true 1; 1.0 [Any[true 1; 1.0 nothing]]]))\n$mat(\n \"true\", 1;\n 1.0, mat(\n \"true\", 1;\n 1.0, #none\n )\n)$\n\njulia> TypstString(1 // 2; block = true)\ntypst\"$ 1 / 2 $\"\n\njulia> typst\"$ \\(1 + 2im; mode = math) $\"\ntypst\"$ (1 + 2i) $\"\n\njulia> TypstCommand([\"help\"])\ntypst`help`\n\njulia> addenv(typst`compile input.typ output.pdf`, \"TYPST_FONT_PATHS\" => julia_mono)\ntypst`compile input.typ output.pdf`","category":"page"},{"location":"#Features","page":"Home","title":"Features","text":"","category":"section"},{"location":"#Strings","page":"Home","title":"Strings","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Print Julia values in Typst format\nSpecify Julia settings and Typst parameters\nImplement formatting for custom types\nConstruct Typst strings\nInterpolate formatted values\nRender in Pluto.jl notebooks","category":"page"},{"location":"#Commands","page":"Home","title":"Commands","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Construct Typst commands\nRender documents using the Typst compiler\nUse the JuliaMono typeface","category":"page"},{"location":"#Planned","page":"Home","title":"Planned","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Support rendering in more environments\nIJulia.jl\nQuarto?\nREPL Unicode?\nOther?\nDefault auto::Mode?\nAutomatically determine the Typst syntactic context\nUse a tree-sitter grammar or jll package\nDocumenter.jl backend and docstrings\nRequires Typst to output HTML\nImplement Typst formatting for more types\nBase\nAbstractDict\nAbstractIrrational\nAbstractSet\nEnum\nMode\nExpr\nSymbol\nPackage extensions\nStandard Library\nLinearAlgebra.jl\nA symbolic TypstFunction?\nMay faciliate Julia to Typst transpilation\nExamples\nTypstString(TypstFunction(eval, :(1//2); mode = code)) == typst\"eval(\"(1 / 2)\", mode: \\\"code\\\")\"\nTypstString(TypstFunction(*, :a, :b; mode = math)) == typst\"(a) (b)\"","category":"page"},{"location":"#Similar-Packages","page":"Home","title":"Similar Packages","text":"","category":"section"},{"location":"#Typst","page":"Home","title":"Typst","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Labelyst.jl\nSummaryTables.jl\nTypstGenerator.jl\nTypstJlyFish.jl\nTypst_jll.jl\nDependency of Typstry.jl","category":"page"},{"location":"#LaTeX","page":"Home","title":"LaTeX","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Latexify.jl\nLaTeXEntities.jl\nLaTeXStrings.jl\nLatexPrint.jl\nLibTeXPrintf.jl\nMakieTeX.jl\nDependent of Typstry.jl\nMathJaxRenderer.jl","category":"page"},{"location":"guides/typst_formatting_examples/#Typst-Formatting-Examples","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"","category":"section"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"This guide illustrates Typst formatting for supported types.","category":"page"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"These Typst documents were generated from Julia using show with the text/typst MIME type and compiled using a TypstCommand. Each row corresponds to a method of show_typst. The Typst columns contain the code, markup, and math syntactical Modes. Each mode contains two columns, where the first is the Typst source text and the second is how that text is rendered in a compiled document. Sequential documents correspond to Package Extensions.","category":"page"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"tip: Tip\nOpen these images in a new tab or another viewer.","category":"page"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"(Image: Typstry.jl examples) (Image: LaTeXStrings.jl examples) (Image: Markdown.jl examples)","category":"page"}] +[{"location":"references/internals/#Internals","page":"Internals","title":"Internals","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"This reference documents non-public utilities.","category":"page"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.compile_workload","category":"page"},{"location":"references/internals/#Typstry.compile_workload","page":"Internals","title":"Typstry.compile_workload","text":"compile_workload(examples)\n\nGiven an iterable of value-type pairs, interpolate each value into a @typst_str within a PrecompileTools.@compile_workload block.\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Strings","page":"Internals","title":"Strings","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.Strings\nTypstry.Strings.examples\nTypstry.Strings.typst_mime\nTypstry.Strings.backticks\nTypstry.Strings.block\nTypstry.Strings.code_mode\nTypstry.Strings.depth\nTypstry.Strings.enclose\nTypstry.Strings.indent\nTypstry.Strings.join_with\nTypstry.Strings.math_mode\nTypstry.Strings.math_pad\nTypstry.Strings.maybe_wrap\nTypstry.Strings.mode\nTypstry.Strings.parenthesize\nTypstry.Strings.show_array\nTypstry.Strings.show_parameters\nTypstry.Strings.show_raw\nTypstry.Strings.show_vector\nTypstry.Strings.static_parse","category":"page"},{"location":"references/internals/#Typstry.Strings","page":"Internals","title":"Typstry.Strings","text":"Strings\n\nThe Julia to Typst interface, a custom string corresponding to Typst source text, and its implementation of the String interface.\n\nExamples\n\njulia> Typstry.Strings\nTypstry.Strings\n\n\n\n\n\n","category":"module"},{"location":"references/internals/#Typstry.Strings.examples","page":"Internals","title":"Typstry.Strings.examples","text":"examples\n\nA constant Vector of Julia values and their corresponding Types implemented for show_typst.\n\n\n\n\n\n","category":"constant"},{"location":"references/internals/#Typstry.Strings.typst_mime","page":"Internals","title":"Typstry.Strings.typst_mime","text":"typst_mime\n\nEquivalent to MIME\"text/typst\"().\n\nExamples\n\njulia> Typstry.Strings.typst_mime\nMIME type text/typst\n\n\n\n\n\n","category":"constant"},{"location":"references/internals/#Typstry.Strings.backticks","page":"Internals","title":"Typstry.Strings.backticks","text":"backticks(io)\n\nReturn to io[:backticks]::Int.\n\nExamples\n\njulia> Typstry.Strings.backticks(IOContext(stdout, :backticks => 3))\n3\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.block","page":"Internals","title":"Typstry.Strings.block","text":"block(io)\n\nReturn io[:block]::Bool.\n\nExamples\n\njulia> Typstry.Strings.block(IOContext(stdout, :block => true))\ntrue\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.code_mode","page":"Internals","title":"Typstry.Strings.code_mode","text":"code_mode(io)\n\nPrint the number sign, unless mode(io) == code.\n\nSee also Mode and mode.\n\nExamples\n\njulia> Typstry.Strings.code_mode(IOContext(stdout, :mode => code))\n\njulia> Typstry.Strings.code_mode(IOContext(stdout, :mode => markup))\n#\n\njulia> Typstry.Strings.code_mode(IOContext(stdout, :mode => math))\n#\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.depth","page":"Internals","title":"Typstry.Strings.depth","text":"depth(io)\n\nReturn io[:depth]::Int.\n\nExamples\n\njulia> Typstry.Strings.depth(IOContext(stdout, :depth => 0))\n0\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.enclose","page":"Internals","title":"Typstry.Strings.enclose","text":"enclose(f, io, x, left, right = reverse(left); kwargs...)\n\nCall f(io, x; kwargs...) between printing left and right, respectfully.\n\nExamples\n\njulia> Typstry.Strings.enclose((io, i; x) -> print(io, i, x), stdout, 1, \"\\$ \"; x = \"x\")\n$ 1x $\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.indent","page":"Internals","title":"Typstry.Strings.indent","text":"indent(io)\n\nReturn \" \" ^ io[:tab_size]::Int.\n\nSee also TypstString.\n\nExamples\n\njulia> Typstry.Strings.indent(IOContext(stdout, :tab_size => 2))\n\" \"\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.join_with","page":"Internals","title":"Typstry.Strings.join_with","text":"join_with(f, io, xs, delimeter; kwargs...)\n\nSimilar to join, except printing with f(io, x; kwargs...).\n\nExamples\n\njulia> Typstry.Strings.join_with((io, i; x) -> print(io, -i, x), stdout, 1:4, \", \"; x = \"x\")\n-1x, -2x, -3x, -4x\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.math_mode","page":"Internals","title":"Typstry.Strings.math_mode","text":"math_mode(f, io, x; kwargs...)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.math_pad","page":"Internals","title":"Typstry.Strings.math_pad","text":"math_pad(io)\n\nReturn \"\", \"\\$\", or \"\\$ \" depending on the block and mode settings.\n\nExamples\n\njulia> Typstry.Strings.math_pad(IOContext(stdout, :mode => math))\n\"\"\n\njulia> Typstry.Strings.math_pad(IOContext(stdout, :block => true, :mode => markup))\n\"\\$ \"\n\njulia> Typstry.Strings.math_pad(IOContext(stdout, :block => false, :mode => markup))\n\"\\$\"\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.maybe_wrap","page":"Internals","title":"Typstry.Strings.maybe_wrap","text":"maybe_wrap(::Any)\n\nWrap the value in Typst unless it is a TypstString or TypstText.\n\nExamples\n\njulia> Typstry.Strings.maybe_wrap(1)\nTypst{Int64}(1)\n\njulia> Typstry.Strings.maybe_wrap(TypstString(1))\ntypst\"$1$\"\n\njulia> Typstry.Strings.maybe_wrap(TypstText(1))\nTypstText{Int64}(1)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.mode","page":"Internals","title":"Typstry.Strings.mode","text":"mode(io)\n\nReturn io[:mode]::Mode.\n\nSee also Mode.\n\nExamples\n\njulia> Typstry.Strings.mode(IOContext(stdout, :mode => code))\ncode::Mode = 0\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.parenthesize","page":"Internals","title":"Typstry.Strings.parenthesize","text":"parenthesize(io)\n\nReturn io[:parenthesize]::Bool.\n\nExamples\n\njulia> Typstry.Strings.parenthesize(IOContext(stdout, :parenthesize => true))\ntrue\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_array","page":"Internals","title":"Typstry.Strings.show_array","text":"show_array(io, x)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_parameters","page":"Internals","title":"Typstry.Strings.show_parameters","text":"show_parameters(io, f, keys, final)\n\nExamples\n\njulia> Typstry.Strings.show_parameters(\n IOContext(stdout, :depth => 0, :tab_size => 2, :delim => typst\"\\\"(\\\"\"),\n \"vec\", [:delim, :gap], true)\nvec(\n delim: \"(\",\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_raw","page":"Internals","title":"Typstry.Strings.show_raw","text":"show_raw(f, io, x, language)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.show_vector","page":"Internals","title":"Typstry.Strings.show_vector","text":"show_vector(io, x)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.static_parse","page":"Internals","title":"Typstry.Strings.static_parse","text":"static_parse(args...; filename, kwargs...)\n\nCall Meta.parse with the filename if it is supported in the current Julia version (at least v1.10).\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Dates.jl","page":"Internals","title":"Dates.jl","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"info: Info\nA Dates.jl package extension would currently print warnings during precompilation. See also the Julia issue #52511","category":"page"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.Strings.date_time\nTypstry.Strings.duration\nTypstry.Strings.dates","category":"page"},{"location":"references/internals/#Typstry.Strings.date_time","page":"Internals","title":"Typstry.Strings.date_time","text":"date_time(::Union{Dates.Date, Dates.Time, Dates.DateTime})\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.duration","page":"Internals","title":"Typstry.Strings.duration","text":"duration(::Union{Dates.Day, Dates.Hour, Dates.Minute, Dates.Second, Dates.Week})\n\nExamples\n\njulia> Typstry.Strings.duration(Dates.Day(1))\n:days\n\njulia> Typstry.Strings.duration(Dates.Hour(1))\n:hours\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Strings.dates","page":"Internals","title":"Typstry.Strings.dates","text":"dates(::Union{\n Dates.Date, Dates.DateTime, Dates.Day, Dates.Hour,\n Dates.Minute, Dates.Second, Dates.Time, Dates.Week\n})\n\nExamples\n\njulia> Typstry.Strings.dates(Dates.Date(1))\n(\"datetime\", (:year, :month, :day), (1, 1, 1))\n\njulia> Typstry.Strings.dates(Dates.Day(1))\n(\"duration\", (:days,), (TypstText{String}(\"1\"),))\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Commands","page":"Internals","title":"Commands","text":"","category":"section"},{"location":"references/internals/","page":"Internals","title":"Internals","text":"Typstry.Commands\nTypstry.Commands.typst_compiler\nTypstry.Commands.apply\nTypstry.Commands.format","category":"page"},{"location":"references/internals/#Typstry.Commands","page":"Internals","title":"Typstry.Commands","text":"Commands\n\nA custom command corresponding to the Typst compiler and its implementation of the Cmd interface.\n\nExamples\n\njulia> Typstry.Commands\nTypstry.Commands\n\n\n\n\n\n","category":"module"},{"location":"references/internals/#Typstry.Commands.typst_compiler","page":"Internals","title":"Typstry.Commands.typst_compiler","text":"typst_compiler\n\nA constant Cmd that is the Typst compiler given by Typst_jll.jl with no additional parameters.\n\n\n\n\n\n","category":"constant"},{"location":"references/internals/#Typstry.Commands.apply","page":"Internals","title":"Typstry.Commands.apply","text":"apply(f, tc, args...; kwargs...)\n\n\n\n\n\n","category":"function"},{"location":"references/internals/#Typstry.Commands.format","page":"Internals","title":"Typstry.Commands.format","text":"format(::Union{MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"})\n\nReturn the image format acronym corresponding to the given MIME.\n\nExamples\n\njulia> Typstry.Commands.format(MIME\"application/pdf\"())\n\"pdf\"\n\njulia> Typstry.Commands.format(MIME\"image/png\"())\n\"png\"\n\njulia> Typstry.Commands.format(MIME\"image/svg+xml\"())\n\"svg\"\n\n\n\n\n\n","category":"function"},{"location":"guides/interoperability/#Interoperability","page":"Interoperability","title":"Interoperability","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"This guide illustrates how to use Typstry.jl in compatible notebooks and packages.","category":"page"},{"location":"guides/interoperability/#Notebooks","page":"Interoperability","title":"Notebooks","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"IJulia.jl, Pluto.jl, and QuartoNotebookRunner.jl each render Typsts and TypstTexts. Pluto.jl and QuartoNotebookRunner.jl also render TypstStrings, whereas IJulia.jl will support them in its next feature release. See also this pull request.","category":"page"},{"location":"guides/interoperability/#Packages","page":"Interoperability","title":"Packages","text":"","category":"section"},{"location":"guides/interoperability/#MakieTeX.jl","page":"Interoperability","title":"MakieTeX.jl","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"note: Note\nThis package re-exports @typst_str and TypstString.","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using Logging: Debug, Warn, disable_logging\ndisable_logging(Warn)","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using CairoMakie, MakieTeX\ndisable_logging(Debug) # hide\nf = Figure(; size = (100, 100));\nLTeX(f[1, 1], TypstDocument(typst\"$1 / x$\"); scale = 5);\nsave(\"makie_tex.svg\", f);","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"(Image: MakieTeX.jl)","category":"page"},{"location":"guides/interoperability/#TypstJlyfish.jl","page":"Interoperability","title":"TypstJlyfish.jl","text":"","category":"section"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using Markdown, Typstry\ns = preamble * typst\"\"\"\n#import \"@preview/jlyfish:0.1.0\": *\n#read-julia-output(json(\"typst_jlyfish.json\"))\n#jl-pkg(\"Typstry\")\n#jl(`using Typstry; typst\"$1 / x$\"`)\n\"\"\"\nwrite(\"typst_jlyfish.typ\", s)\nMarkdown.parse(\"`````typst\\n\" * s * \"\\n`````\")","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"using TypstJlyfish\nTypstJlyfish.compile(\"typst_jlyfish.typ\";\n evaluation_file = \"typst_jlyfish.json\",\n typst_compile_args = \"--format=svg\"\n)","category":"page"},{"location":"guides/interoperability/","page":"Interoperability","title":"Interoperability","text":"(Image: TypstJlyfish.jl)","category":"page"},{"location":"guides/the_julia_to_typst_interface/#The-Julia-to-Typst-Interface","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"This guide illustrates how to implement Typst formatting for custom types.","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Setup","page":"The Julia to Typst Interface","title":"Setup","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> import Base: show\n\njulia> import Typstry: context, show_typst\n\njulia> using Typstry","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Implementation","page":"The Julia to Typst Interface","title":"Implementation","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Consider this custom type.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> struct Reciprocal{N <: Number}\n n::N\n end","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Implement a show_typst method to specify its Typst formatting. Remember to Annotate values taken from untyped locations.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> show_typst(io, r::Reciprocal) =\n if io[:mode]::Mode == markup\n print(io, \"#let reciprocal(n) = \\$1 / #n\\$\")\n else\n print(io, \"reciprocal(\")\n show(io, MIME\"text/typst\"(), Typst(round(r.n; digits = io[:digits]::Int)))\n print(io, \")\")\n end;","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Although custom formatting may be handled in show_typst with get(io, key, default), this may be repetitive when specifying defaults for multiple methods. There is also no way to tell if the value has been specified by the user or if it is a default. Instead, implement a custom context which overrides default, but not user specifications.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> context(::Reciprocal) = Dict(:digits => 2);","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Those two methods are a complete implementation of the Julia to Typst interface. The following method is optional:","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> show(io::IO, m::MIME\"text/typst\", r::Reciprocal) = show(io, m, Typst(r));","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Now, a Reciprocal is fully supported by Typstry.jl.","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> r = Reciprocal(π);\n\njulia> println(TypstString(r))\n#let reciprocal(n) = $1 / #n$\n\njulia> println(TypstString(r; mode = math))\nreciprocal(3.14)\n\njulia> println(TypstString(r; mode = math, digits = 4))\nreciprocal(3.1416)","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Guidelines","page":"The Julia to Typst Interface","title":"Guidelines","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"While implementing the interface only requires two methods, it may be more challenging to determine how a Julia value should be represented in a Typst source file and its corresponding compiled document. Julia and Typst are distinct languages that differ in both syntax and semantics, so there may be multiple meaningful formats to choose from.","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Make-the-obvious-choice,-if-available","page":"The Julia to Typst Interface","title":"Make the obvious choice, if available","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"There is a clear correspondence between these Julia and Typst values","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(1))\n$1$\n\njulia> println(TypstString(nothing))\n#none\n\njulia> println(TypstString(r\"[a-z]\"))\n#regex(\"[a-z]\")","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Choose-the-most-semantically-rich-representation","page":"The Julia to Typst Interface","title":"Choose the most semantically rich representation","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"This may vary across Modes and domains\nSome modes may not have a meaningful representation, and should be formatted into a mode that does\nBoth Julia and Typst support Unicode characters, except unknown variables in Typst's code mode","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(π; mode = code))\n3.141592653589793\n\njulia> println(TypstString(π; mode = math))\nπ\n\njulia> println(TypstString(π; mode = markup))\n$π$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Consider-both-the-Typst-source-text-and-compiled-document-formatting","page":"The Julia to Typst Interface","title":"Consider both the Typst source text and compiled document formatting","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"A Docs.Text is documented to \"render [its value] as plain text\", and therefore corresponds to text in a rendered Typst document\nA TypstString represents Typst source text, and is printed directly","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(text\"[\\\"a\\\"]\"))\n[\"a\"]\n\njulia> println(TypstString(typst\"[\\\"a\\\"]\"))\n[\"a\"]","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Try-to-generate-valid-Typst-source-text","page":"The Julia to Typst Interface","title":"Try to generate valid Typst source text","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"A TypstString represents Typst source text, which may be invalid\nA UnitRange{Int} is formatted differently for each Mode, but is always valid","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(1:4; mode = code))\nrange(1, 5)\n\njulia> println(TypstString(1:4; mode = math))\nvec(\n 1, 2, 3, 4\n)\n\njulia> println(TypstString(1:4; mode = markup))\n$vec(\n 1, 2, 3, 4\n)$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Test-for-edge-cases","page":"The Julia to Typst Interface","title":"Test for edge cases","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"#1 / 2 is valid Typst source text, but is parsed partially in code mode as (#1) / 2\n1 / 2 may be ambiguous in a math mode expression\n$1 / 2$ is not ambiguous in markup mode","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(1 // 2; mode = code))\n(1 / 2)\n\njulia> println(TypstString(1 // 2; mode = math))\n(1 / 2)\n\njulia> println(TypstString(1 // 2; mode = markup))\n$1 / 2$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Format-values-in-containers-using-show-with-the-text/typst-MIME-type","page":"The Julia to Typst Interface","title":"Format values in containers using show with the text/typst MIME type","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Values may require some of their context\nThe AbstractVector method changes its Mode to math and increments its depth","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString([true, 1, Any[1.2, 1 // 2]]))\n$vec(\n \"true\", 1, vec(\n 1.2, 1 / 2\n )\n)$","category":"page"},{"location":"guides/the_julia_to_typst_interface/#Check-parametric-and-abstract-types","page":"The Julia to Typst Interface","title":"Check parametric and abstract types","text":"","category":"section"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"Related Julia types may not be representable in the same Typst format","category":"page"},{"location":"guides/the_julia_to_typst_interface/","page":"The Julia to Typst Interface","title":"The Julia to Typst Interface","text":"julia> println(TypstString(0:2:6; mode = code))\nrange(0, 7, step: 2)\n\njulia> println(TypstString(0:2.0:6; mode = code))\n(0.0, 2.0, 4.0, 6.0)","category":"page"},{"location":"references/strings/#Strings","page":"Strings","title":"Strings","text":"","category":"section"},{"location":"references/strings/","page":"Strings","title":"Strings","text":"using Markdown, Typstry\nMarkdown.parse(\"This reference documents \" * lowercasefirst(split(string(@doc Typstry.Strings), \"\\n\")[5]))","category":"page"},{"location":"references/strings/#Typstry","page":"Strings","title":"Typstry","text":"","category":"section"},{"location":"references/strings/","page":"Strings","title":"Strings","text":"Mode\nTypst\nTypstString\nTypstText\n@typst_str\ncode\nmarkup\nmath\ncontext\nshow_typst(::Any, ::AbstractChar)","category":"page"},{"location":"references/strings/#Typstry.Strings.Mode","page":"Strings","title":"Typstry.Strings.Mode","text":"Mode\n\nAn Enumerated type used to specify that the current Typst syntactical context is code, markup, or math.\n\nExamples\n\njulia> Mode\nEnum Mode:\ncode = 0\nmarkup = 1\nmath = 2\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.Typst","page":"Strings","title":"Typstry.Strings.Typst","text":"Typst{T}\nTypst(::T)\n\nA wrapper used to pass values to show(::IO, ::MIME\"text/typst\", ::Typst).\n\nExamples\n\njulia> Typst(1)\nTypst{Int64}(1)\n\njulia> Typst(\"a\")\nTypst{String}(\"a\")\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.TypstString","page":"Strings","title":"Typstry.Strings.TypstString","text":"TypstString <: AbstractString\nTypstString(::Any; context...)\n\nConvert the value to a Typst formatted string.\n\nOptional Julia settings and Typst parameters are passed to show(::IO, ::MIME\"text/typst\", ::Typst) in an IOContext. See also show_typst for a list of supported types.\n\ninfo: Info\nThis type implements the String interface. However, the interface is unspecified, which may result in unexpected behavior.\n\nExamples\n\njulia> TypstString(1)\ntypst\"$1$\"\n\njulia> TypstString(1 + 2im; mode = math)\ntypst\"(1 + 2i)\"\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.TypstText","page":"Strings","title":"Typstry.Strings.TypstText","text":"TypstText{T}\nTypstText(::Any)\n\nA wrapper whose show_typst method uses print.\n\ninfo: Info\nThis may be used to insert control characters into a TypstString. Unescaped control characters in TypstStrings may break formatting in some environments, such as the REPL.\n\nExamples\n\njulia> TypstText(1)\nTypstText{Int64}(1)\n\njulia> TypstText(\"a\")\nTypstText{String}(\"a\")\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Typstry.Strings.@typst_str","page":"Strings","title":"Typstry.Strings.@typst_str","text":"@typst_str(s)\ntypst\"s\"\n\nConstruct a TypstString.\n\nControl characters are escaped, except double quotation marks and backslashes in the same manner as @raw_str. Values may be interpolated by calling the TypstString constructor, except using a backslash instead of the type name. Interpolation syntax may be escaped in the same manner as quotation marks.\n\ntip: Tip\nPrint directly to an IO using show(::IO, ::MIME\"text/typst\", ::Typst).See also the performance tip to Avoid string interpolation for I/O.\n\nExamples\n\njulia> x = 1;\n\njulia> typst\"$ \\(x; mode = math) / \\(x + 1; mode = math) $\"\ntypst\"$ 1 / 2 $\"\n\njulia> typst\"\\(x//2)\"\ntypst\"$1 / 2$\"\n\njulia> typst\"\\(x // 2; mode = math)\"\ntypst\"(1 / 2)\"\n\njulia> typst\"\\\\(x)\"\ntypst\"\\\\(x)\"\n\n\n\n\n\n","category":"macro"},{"location":"references/strings/#Typstry.Strings.code","page":"Strings","title":"Typstry.Strings.code","text":"code\n\nA Typst syntactical Mode prefixed by the number sign.\n\nExamples\n\njulia> code\ncode::Mode = 0\n\n\n\n\n\n","category":"constant"},{"location":"references/strings/#Typstry.Strings.markup","page":"Strings","title":"Typstry.Strings.markup","text":"markup\n\nA Typst syntactical Mode at the top-level of source text and enclosed within square brackets.\n\njulia> markup\nmarkup::Mode = 1\n\n\n\n\n\n","category":"constant"},{"location":"references/strings/#Typstry.Strings.math","page":"Strings","title":"Typstry.Strings.math","text":"math\n\nA Typst syntactical Mode enclosed within dollar signs.\n\njulia> math\nmath::Mode = 2\n\n\n\n\n\n","category":"constant"},{"location":"references/strings/#Typstry.Strings.context","page":"Strings","title":"Typstry.Strings.context","text":"context(x)\n\nProvide formatting data for show(::IO, ::MIME\"text/typst\", ::Typst).\n\nImplement this function for a custom type to specify its custom settings and parameters. Passing a value wrapped in Typst will merge! its custom context with defaults, such that the defaults may be overwritten. To be compatible with merging contexts and constructing an IOContext, methods must return an AbstractDict{Symbol}.\n\nSetting Default Type Description\n:backticks 3 Int The number of backticks to enclose raw text markup, which may be increased to disambiguiate nested raw text.\n:block false Bool When :mode => math, specifies whether the enclosing dollar signs are padded with a space to render the element inline or its own block.\n:depth 0 Int The current level of nesting within container types to specify the degree of indentation.\n:mode markup Mode The current Typst syntactical context where code follows the number sign, markup is at the top-level and enclosed in square brackets, and math is enclosed in dollar signs.\n:parenthesize true Bool Whether to enclose some mathematical elements in parentheses to specify their operator precedence and avoid ambiguity.\n:tab_size 2 Int The number of spaces used by some elements with multi-line Typst formatting, which is repeated for each level of depth\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Typstry.Strings.show_typst-Tuple{Any, AbstractChar}","page":"Strings","title":"Typstry.Strings.show_typst","text":"show_typst(io, x)\n\nPrint in Typst format with Julia settings and Typst parameters provided by an IOContext.\n\nImplement this function for a custom type to specify its Typst formatting. A setting is a value used in Julia, whose type varies across settings. A parameter is passed directly to a Typst function and must be a TypstString with the same name as in Typst, except that dashes are replaced with underscores. Some settings, such as block, correspond with a parameter but may be used in Julia.\n\nFor additional information on settings and parameters, see also context and the Typst Documentation, respectively.\n\ninfo: Info\nSome types, particularly containers, may call show(::IO, ::MIME\"text/typst\", ::Typst) to format a value, which may use additional settings and parameters.\n\nwarning: Warning\nThis function's methods are incomplete. Please file an issue or create a pull-request for missing methods.\n\nType Settings Parameters\nAbstractArray :block, :depth, :mode, :tab_size :delim, :gap\nAbstractChar \nAbstractFloat :mode \nAbstractMatrix :block, :depth, :mode, :tab_size :augment, :column_gap, :delim, :gap, :row_gap\nAbstractString \nBool :mode \nComplex{Bool} :block, :mode, :parenthesize \nComplex :block, :mode, :parenthesize \nIrrational :mode \nNothing :mode \nOrdinalRange{<:Integer, <:Integer} :mode \nRational :block, :mode, :parenthesize \nRegex :mode \nSigned :mode \nStepRangeLen{<:Integer, <:Integer, <:Integer} :mode \nString :mode \nTuple :block, :depth, :mode, :tab_size :delim, :gap\nTypst \nTypstString \nTypstText :mode \nUnsigned :mode \nVersionNumber :mode \nDocs.HTML :block, :depth, :mode, :tab_size \nDocs.Text :mode \nDates.Date :mode, :indent \nDates.DateTime :mode, :indent \nDates.Day :mode, :indent \nDates.Hour :mode, :indent \nDates.Minute :mode, :indent \nDates.Second :mode, :indent \nDates.Time :mode, :indent \nDates.Week :mode, :indent \n\n\n\n\n\n","category":"method"},{"location":"references/strings/#Base","page":"Strings","title":"Base","text":"","category":"section"},{"location":"references/strings/","page":"Strings","title":"Strings","text":"IOBuffer\ncodeunit\nisvalid\niterate(::TypstString)\nncodeunits\npointer\nrepr\nshow(::IO, ::TypstString)\nshow(::IO, ::MIME\"text/typst\", ::Typst)","category":"page"},{"location":"references/strings/#Base.IOBuffer","page":"Strings","title":"Base.IOBuffer","text":"IOBuffer(::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> IOBuffer(typst\"a\")\nIOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=1, maxsize=Inf, ptr=1, mark=-1)\n\n\n\n\n\n","category":"type"},{"location":"references/strings/#Base.codeunit","page":"Strings","title":"Base.codeunit","text":"codeunit(::TypstString)\ncodeunit(::TypstString, ::Integer)\n\nSee also TypstString.\n\nExamples\n\njulia> codeunit(typst\"a\")\nUInt8\n\njulia> codeunit(typst\"a\", 1)\n0x61\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.isvalid","page":"Strings","title":"Base.isvalid","text":"isvalid(::TypstString, ::Integer)\n\nSee also TypstString.\n\nExamples\n\njulia> isvalid(typst\"a\", 1)\ntrue\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.iterate-Tuple{TypstString}","page":"Strings","title":"Base.iterate","text":"iterate(::TypstString, ::Integer)\niterate(::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> iterate(typst\"a\")\n('a', 2)\n\njulia> iterate(typst\"a\", 1)\n('a', 2)\n\n\n\n\n\n","category":"method"},{"location":"references/strings/#Base.ncodeunits","page":"Strings","title":"Base.ncodeunits","text":"ncodeunits(::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> ncodeunits(typst\"a\")\n1\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.pointer","page":"Strings","title":"Base.pointer","text":"pointer(::TypstString)\n\nSee also TypstString.\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.repr","page":"Strings","title":"Base.repr","text":"repr(::MIME, ::TypstString; kwargs...)\n\nSee also TypstString.\n\ninfo: Info\nThis method patches incorrect output from the assumption in repr that the parameter is already in the requested MIME type when the MIME type istextmime and the parameter is an AbstractString.\n\nExamples\n\njulia> repr(\"text/plain\", typst\"a\")\n\"typst\\\"a\\\"\"\n\njulia> repr(\"text/typst\", typst\"a\")\ntypst\"a\"\n\n\n\n\n\n","category":"function"},{"location":"references/strings/#Base.show-Tuple{IO, TypstString}","page":"Strings","title":"Base.show","text":"show(::IO, ::TypstString)\n\nSee also TypstString.\n\nExamples\n\njulia> show(stdout, typst\"a\")\ntypst\"a\"\n\n\n\n\n\n","category":"method"},{"location":"references/strings/#Base.show-Tuple{IO, MIME{Symbol(\"text/typst\")}, Typst}","page":"Strings","title":"Base.show","text":"show(::IO, ::MIME\"text/typst\", ::Union{Typst, TypstString, TypstText})\n\nPrint the Typst format.\n\nThis method provides formatting data to show_typst specified by a default and custom context.\n\nSee also TypstString and TypstText.\n\nExamples\n\njulia> show(stdout, \"text/typst\", typst\"a\")\na\n\njulia> show(stdout, \"text/typst\", Typst(\"a\"))\n\"a\"\n\njulia> show(stdout, \"text/typst\", Typst(Text(\"a\")))\na\n\n\n\n\n\n","category":"method"},{"location":"references/package_extensions/#Package-Extensions","page":"Package Extensions","title":"Package Extensions","text":"","category":"section"},{"location":"references/package_extensions/","page":"Package Extensions","title":"Package Extensions","text":"This reference documents the lazily-loaded implementations of show_typst for types defined in external packages.","category":"page"},{"location":"references/package_extensions/#LaTeXStrings.jl","page":"Package Extensions","title":"LaTeXStrings.jl","text":"","category":"section"},{"location":"references/package_extensions/","page":"Package Extensions","title":"Package Extensions","text":"show_typst(::Any, ::LaTeXStrings.LaTeXString)","category":"page"},{"location":"references/package_extensions/#Typstry.Strings.show_typst-Tuple{Any, LaTeXString}","page":"Package Extensions","title":"Typstry.Strings.show_typst","text":"show_typst(io, ::LaTeXString)\n\nPrint in Typst format for LaTeXStrings.jl.\n\nType Settings Parameters\nLaTeXString :block, :depth, :mode, :tab_size \n\n\n\n\n\n","category":"method"},{"location":"references/package_extensions/#Markdown.jl","page":"Package Extensions","title":"Markdown.jl","text":"","category":"section"},{"location":"references/package_extensions/","page":"Package Extensions","title":"Package Extensions","text":"show_typst(::Any, ::Markdown.MD)","category":"page"},{"location":"references/package_extensions/#Typstry.Strings.show_typst-Tuple{Any, MD}","page":"Package Extensions","title":"Typstry.Strings.show_typst","text":"show_typst(io, ::Markdown.MD)\n\nPrint in Typst format for Markdown.jl.\n\nType Settings Parameters\nMarkdown.MD :block, :depth, :mode, :tab_size \n\n\n\n\n\n","category":"method"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"DocTestSetup = :(using Typstry)","category":"page"},{"location":"tutorials/getting_started/#Getting-Started","page":"Getting Started","title":"Getting Started","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"This tutorial demonstrates the basic features of Typstry.jl and how to use them.","category":"page"},{"location":"tutorials/getting_started/#Strings","page":"Getting Started","title":"Strings","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Print Julia values in Typst format using show with the text/typst MIME type. This formatting is also used to create a TypstString.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> show(stdout, \"text/typst\", Typst(π))\n$π$\n\njulia> TypstString(π)\ntypst\"$π$\"","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Methods of show_typst are used to specify the Typst formatting, which may use Julia settings and Typst parameters. A setting is a value used in Julia, whereas a parameter is passed directly to a Typst function. Settings each have a default value, whereas the default values of parameters are handled by Typst functions. This context may instead be specified in show using an IOContext and in TypstString using keyword parameters.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> show(IOContext(stdout, :mode => code), \"text/typst\", Typst(π))\n3.141592653589793\n\njulia> TypstString(π; mode = code)\ntypst\"3.141592653589793\"","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Use @typst_str to directly write Typst source text. This also supports formatted interpolation by calling the TypstString constructor.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> typst\"$ \\(pi; mode = math) approx \\(pi; mode = code) $\"\ntypst\"$ π approx 3.141592653589793 $\"","category":"page"},{"location":"tutorials/getting_started/#Commands","page":"Getting Started","title":"Commands","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Use render to easily generate a Typst source file and compile it into a document.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> render(Any[true 1; 1.2 1 // 2]);","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"Compile source files by running a TypstCommand created using its constructor or @typst_cmd.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting Started","title":"Getting Started","text":"julia> TypstCommand([\"help\"])\ntypst`help`\n\njulia> run(typst`compile input.typ output.pdf`);","category":"page"},{"location":"references/commands/#Commands","page":"Commands","title":"Commands","text":"","category":"section"},{"location":"references/commands/","page":"Commands","title":"Commands","text":"using Markdown, Typstry\nMarkdown.parse(\"This reference documents \" * lowercasefirst(split(string(@doc Typstry.Commands), \"\\n\")[5]))","category":"page"},{"location":"references/commands/#Typstry","page":"Commands","title":"Typstry","text":"","category":"section"},{"location":"references/commands/","page":"Commands","title":"Commands","text":"TypstCommand\nTypstError\n@typst_cmd\njulia_mono\npreamble\nrender","category":"page"},{"location":"references/commands/#Typstry.Commands.TypstCommand","page":"Commands","title":"Typstry.Commands.TypstCommand","text":"TypstCommand(::Vector{String})\nTypstCommand(::TypstCommand; kwargs...)\n\nThe Typst compiler and its parameters.\n\ninfo: Info\nThis type implements the Cmd interface. However, the interface is unspecified, which may result in unexpected behavior.\n\nExamples\n\njulia> help = TypstCommand([\"help\"])\ntypst`help`\n\njulia> TypstCommand(help; ignorestatus = true)\ntypst`help`\n\n\n\n\n\n","category":"type"},{"location":"references/commands/#Typstry.Commands.TypstError","page":"Commands","title":"Typstry.Commands.TypstError","text":"TypstError <: Exception\nTypstError(::TypstCommand)\n\nAn Exception indicating a failure to run a TypstCommand.\n\n\n\n\n\n","category":"type"},{"location":"references/commands/#Typstry.Commands.@typst_cmd","page":"Commands","title":"Typstry.Commands.@typst_cmd","text":"@typst_cmd(s)\ntypst`s`\n\nConstruct a TypstCommand where each parameter is separated by a space.\n\nThis does not support interpolation; use the constructor instead.\n\nExamples\n\njulia> typst`help`\ntypst`help`\n\njulia> typst`compile input.typ output.typ`\ntypst`compile input.typ output.typ`\n\n\n\n\n\n","category":"macro"},{"location":"references/commands/#Typstry.Commands.julia_mono","page":"Commands","title":"Typstry.Commands.julia_mono","text":"julia_mono\n\nAn constant artifact containing the JuliaMono typeface.\n\nUse with a TypstCommand and one of addenv, setenv, or the font-path Typst command-line option.\n\n\n\n\n\n","category":"constant"},{"location":"references/commands/#Typstry.Commands.preamble","page":"Commands","title":"Typstry.Commands.preamble","text":"preamble\n\nA constant used at the beginning of Typst source files generated by show(::IO, ::Union{MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"}, ::TypstString).\n\nExamples\n\njulia> println(Typstry.Commands.preamble)\n#set page(margin: 1em, height: auto, width: auto, fill: white)\n#set text(16pt, font: \"JuliaMono\")\n\n\n\n\n\n","category":"constant"},{"location":"references/commands/#Typstry.Commands.render","page":"Commands","title":"Typstry.Commands.render","text":"render(x;\n input = \"input.typ\",\n output = \"output.pdf\",\n open = true,\n preamble = Typstry.preamble,\ncontext...)\n\nRender to a document using show(::IO, ::MIME\"text/typst\", ::Typst).\n\nThis first generates the input file containing Typst source text with the preamble and formatted value. Then it is compiled into 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.\n\nSee also preamble.\n\nExamples\n\njulia> render(Any[true 1; 1.2 1 // 2]);\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base","page":"Commands","title":"Base","text":"","category":"section"},{"location":"references/commands/","page":"Commands","title":"Commands","text":"==\naddenv\ndetach\neltype\nfirstindex\ngetindex\nhash\nignorestatus\niterate(::TypstCommand)\nkeys\nlastindex\nlength\nrun\nsetcpuaffinity\nsetenv\nshow(::IO, ::MIME\"text/plain\", ::TypstCommand)\nshow(::IO, ::Union{MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"}, ::Union{Typst, TypstString, TypstText})\nshowerror","category":"page"},{"location":"references/commands/#Base.:==","page":"Commands","title":"Base.:==","text":"==(::TypstCommand, ::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> help = typst`help`\ntypst`help`\n\njulia> help == help\ntrue\n\njulia> help == TypstCommand(help; ignorestatus = true)\nfalse\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.addenv","page":"Commands","title":"Base.addenv","text":"addenv(::TypstCommand, args...; kwargs...)\n\nSee also TypstCommand and julia_mono.\n\nExamples\n\njulia> addenv(typst`compile input.typ output.pdf`, \"TYPST_FONT_PATHS\" => julia_mono)\ntypst`compile input.typ output.pdf`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.detach","page":"Commands","title":"Base.detach","text":"detach(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> detach(typst`help`)\ntypst`help`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.eltype","page":"Commands","title":"Base.eltype","text":"eltype(::Type{TypstCommand})\n\nSee also TypstCommand.\n\nExamples\n\njulia> eltype(TypstCommand)\nString\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.firstindex","page":"Commands","title":"Base.firstindex","text":"firstindex(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> firstindex(typst`help`)\n1\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.getindex","page":"Commands","title":"Base.getindex","text":"getindex(::TypstCommand, i)\n\nSee also TypstCommand.\n\nExamples\n\njulia> typst`help`[2]\n\"help\"\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.hash","page":"Commands","title":"Base.hash","text":"hash(::TypstCommand, ::UInt)\n\nSee also TypstCommand.\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.ignorestatus","page":"Commands","title":"Base.ignorestatus","text":"ignorestatus(::TypstCommand)\n\nReturn a TypstCommand that does not throw a TypstError if the Typst compiler throws an error.\n\nErrors thrown by the Typst compiler are printed to stderr regardless.\n\nExamples\n\njulia> ignorestatus(typst`help`)\ntypst`help`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.iterate-Tuple{TypstCommand}","page":"Commands","title":"Base.iterate","text":"iterate(::TypstCommand)\niterate(::TypstCommand, i)\n\nSee also TypstCommand.\n\nExamples\n\njulia> iterate(typst`help`, 2)\n(\"help\", 3)\n\njulia> iterate(typst`help`, 3)\n\n\n\n\n\n","category":"method"},{"location":"references/commands/#Base.keys","page":"Commands","title":"Base.keys","text":"keys(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> keys(typst`help`)\n2-element LinearIndices{1, Tuple{Base.OneTo{Int64}}}:\n 1\n 2\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.lastindex","page":"Commands","title":"Base.lastindex","text":"lastindex(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> lastindex(typst`help`)\n2\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.length","page":"Commands","title":"Base.length","text":"length(::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> length(typst`help`)\n2\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.run","page":"Commands","title":"Base.run","text":"run(::TypstCommand, args...; kwargs...)\n\nSee also TypstCommand.\n\ninfo: Info\nIf the Typst compiler throws an error, it will be printed to stderr. Then, a Julia TypstError will be thrown unless the ignorestatus flag is set.\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.setcpuaffinity","page":"Commands","title":"Base.setcpuaffinity","text":"setcpuaffinity(::TypstCommand, cpus)\n\nSee also TypstCommand.\n\ncompat: Compat\nRequires at least Julia v0.8.\n\nExamples\n\njulia> setcpuaffinity(typst`help`, nothing)\ntypst`help`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.setenv","page":"Commands","title":"Base.setenv","text":"setenv(::TypstCommand, args...; kwargs...)\n\nSee also TypstCommand and julia_mono.\n\nExamples\n\njulia> setenv(typst`compile input.typ output.pdf`, \"TYPST_FONT_PATHS\" => julia_mono)\ntypst`compile input.typ output.pdf`\n\n\n\n\n\n","category":"function"},{"location":"references/commands/#Base.show-Tuple{IO, MIME{Symbol(\"text/plain\")}, TypstCommand}","page":"Commands","title":"Base.show","text":"show(::IO, ::MIME\"text/plain\", ::TypstCommand)\n\nSee also TypstCommand.\n\nExamples\n\njulia> show(stdout, \"text/plain\", typst`help`)\ntypst`help`\n\n\n\n\n\n","category":"method"},{"location":"references/commands/#Base.show-Tuple{IO, Union{MIME{Symbol(\"application/pdf\")}, MIME{Symbol(\"image/png\")}, MIME{Symbol(\"image/svg+xml\")}}, Union{TypstString, Typst, TypstText}}","page":"Commands","title":"Base.show","text":"show(::IO, ::Union{\n MIME\"application/pdf\", MIME\"image/png\", MIME\"image/svg+xml\"\n}, ::Union{Typst, TypstString, TypstText})\n\nPrint the Portable Document Format (PDF), Portable Network Graphics (PNG), or Scalable Vector Graphics (SVG) format.\n\nThe preamble keyword parameter used by render may be specified in an IOContext.\n\nEnvironments, such as Pluto.jl notebooks, may use these methods to display Typsts, TypstStrings, and TypstTexts.\n\n\n\n\n\n","category":"method"},{"location":"references/commands/#Base.showerror","page":"Commands","title":"Base.showerror","text":"showerror(::IO, ::TypstError)\n\nPrint a TypstError when failing to run a TypstCommand.\n\nExamples\n\njulia> showerror(stdout, TypstError(typst``))\nTypstError: failed to `run` a `TypstCommand(String[])`\n\n\n\n\n\n","category":"function"},{"location":"","page":"Home","title":"Home","text":"DocTestSetup = :(using Typstry)","category":"page"},{"location":"#Home","page":"Home","title":"Home","text":"","category":"section"},{"location":"#Introduction","page":"Home","title":"Introduction","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Typstry.jl is the interface to convert the computational power of Julia into beautifully formatted Typst documents.","category":"page"},{"location":"#What-is-Typst?","page":"Home","title":"What is Typst?","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Typst is an open-source and relatively new typesetting system (written in Rust 🦀🚀), designed to improve upon the performance and usability of LaTeX. See also the Typst repository and documentation for examples and how to get started.","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"julia> using Pkg: add\n\njulia> add(\"Typstry\")\n\njulia> using Typstry","category":"page"},{"location":"#Showcase","page":"Home","title":"Showcase","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"julia> show_typst(IOContext(stdout, :mode => code), true)\ntrue\n\njulia> show(stdout, \"text/typst\", Typst([true 1; 1.0 [Any[true 1; 1.0 nothing]]]))\n$mat(\n \"true\", 1;\n 1.0, mat(\n \"true\", 1;\n 1.0, #none\n )\n)$\n\njulia> TypstString(1 // 2; block = true)\ntypst\"$ 1 / 2 $\"\n\njulia> typst\"$ \\(1 + 2im; mode = math) $\"\ntypst\"$ (1 + 2i) $\"\n\njulia> TypstCommand([\"help\"])\ntypst`help`\n\njulia> typst`compile input.typ output.pdf`\ntypst`compile input.typ output.pdf`","category":"page"},{"location":"#Features","page":"Home","title":"Features","text":"","category":"section"},{"location":"#Strings","page":"Home","title":"Strings","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Print Julia values in Typst format\nSpecify Julia settings and Typst parameters\nImplement formatting for custom types\nConstruct Typst strings\nInterpolate formatted values\nRender in IJulia.jl, Pluto.jl, and QuartoRunner.jl notebooks","category":"page"},{"location":"#Commands","page":"Home","title":"Commands","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Construct Typst commands\nRender documents using the Typst compiler\nUse the JuliaMono typeface","category":"page"},{"location":"#Planned","page":"Home","title":"Planned","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Support rendering in more environments\nIJulia.jl\nREPL Unicode?\nOther?\nDefault auto::Mode?\nAutomatically determine the Typst syntactic context\nUse a tree-sitter grammar or jll package\nDocumenter.jl backend and docstrings\nRequires Typst to output HTML\nImplement Typst formatting for more types\nBase\nAbstractDict\nAbstractIrrational\nAbstractSet\nEnum\nMode\nExpr\nSymbol\nPackage extensions\nStandard Library\nLinearAlgebra.jl\nA symbolic TypstFunction?\nMay faciliate Julia to Typst transpilation\nExamples\nTypstString(TypstFunction(eval, :(1//2); mode = code)) == typst\"eval(\"(1 / 2)\", mode: \\\"code\\\")\"\nTypstString(TypstFunction(*, :a, :b; mode = math)) == typst\"(a) (b)\"","category":"page"},{"location":"#Similar-Packages","page":"Home","title":"Similar Packages","text":"","category":"section"},{"location":"#Typst","page":"Home","title":"Typst","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Labelyst.jl\nSummaryTables.jl\nTypstGenerator.jl\nTypstJlyFish.jl\nInteroperable with Typstry.jl\nTypst_jll.jl\nDependency of Typstry.jl","category":"page"},{"location":"#LaTeX","page":"Home","title":"LaTeX","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Latexify.jl\nLaTeXEntities.jl\nLaTeXStrings.jl\nLatexPrint.jl\nLibTeXPrintf.jl\nMakieTeX.jl\nDependent of Typstry.jl\nMathJaxRenderer.jl","category":"page"},{"location":"guides/typst_formatting_examples/#Typst-Formatting-Examples","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"","category":"section"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"This guide illustrates Typst formatting for supported types.","category":"page"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"These Typst documents were generated from Julia using show with the text/typst MIME type and compiled using a TypstCommand. Each row corresponds to a method of show_typst. The Typst columns contain the code, markup, and math syntactical Modes. Each mode contains two columns, where the first is the Typst source text and the second is how that text is rendered in a compiled document. Sequential documents correspond to Package Extensions.","category":"page"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"tip: Tip\nOpen these images in a new tab or another viewer.","category":"page"},{"location":"guides/typst_formatting_examples/","page":"Typst Formatting Examples","title":"Typst Formatting Examples","text":"(Image: Typstry.jl examples) (Image: LaTeXStrings.jl examples) (Image: Markdown.jl examples)","category":"page"}] } diff --git a/development/tutorials/getting_started/index.html b/development/tutorials/getting_started/index.html index bc8e505..8d11ad2 100644 --- a/development/tutorials/getting_started/index.html +++ b/development/tutorials/getting_started/index.html @@ -11,4 +11,4 @@ typst"$ π approx 3.141592653589793 $"

Commands

Use render to easily generate a Typst source file and compile it into a document.

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

Compile source files by running a TypstCommand created using its constructor or @typst_cmd.

julia> TypstCommand(["help"])
 typst`help`
 
-julia> run(typst`compile input.typ output.pdf`);
+julia> run(typst`compile input.typ output.pdf`);