Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Typstry.jl to v0.3.0 (#55) #62

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Makie = "0.21.2"
Poppler_jll = "21.9, 22, 23"
Rsvg = "1"
julia = "1.9"
Typstry = "0.2, 0.3"
Typstry = "0.3"
tectonic_jll = "0"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fig
```@example main
using MakieTeX, CairoMakie

typst_string = typst"$ integral_0^pi sin(x)^2 diff x $";
typst_string = typst"$ integral_0^pi sin(x)^2 dif x $";
typst_document = TypstDocument(typst_string);
cached_typst = CachedTypst(typst_document);

Expand Down
12 changes: 8 additions & 4 deletions src/rendering/typst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ Compile the given document as a String and return the resulting PDF (also as a S
"""
function compile_typst(document::AbstractString)
#=
Typst_jll v0.11+ supports compiling from `stdin`.
It does not yet support compiling to `stdout`.
Typst_jll v0.11+ supports reading from `stdin`.
Typst_jll v0.12+ will likely support writing to `stdout`.

See also:
https://github.com/typst/typst/issues/410
https://github.com/typst/typst/pull/3339
https://github.com/typst/typst/pull/3632
=#
return mktempdir() do dir
cd(dir) do
Expand All @@ -37,9 +38,12 @@ function compile_typst(document::AbstractString)
err = Pipe()

try
# `pipeline` is not yet supported for `TypstCommand`
# `pipeline` is not yet supported for `TypstCommand`.
# We need to add Julia Mono as a typst font, but don't want to override user env specs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch! This got me to fix the same issue in a few methods for v0.4 :)

_separator = Sys.iswindows() ? ";" : ":"
TYPST_FONT_PATHS = haskey(ENV, "TYPST_FONT_PATHS") ? "$(ENV["TYPST_FONT_PATHS"])$(_separator)$(Typstry.julia_mono)" : Typstry.julia_mono
redirect_stdio(stdout=out, stderr=err) do
run(ignorestatus(typst`compile temp.typ`))
run(ignorestatus(addenv(typst`compile temp.typ`, "TYPST_FONT_PATHS" => TYPST_FONT_PATHS)))
end

close(out.in)
Expand Down
Loading