From 2460795ff74a34e2a2989c104c276804279e9f0d Mon Sep 17 00:00:00 2001 From: Jakob Peters Date: Sat, 13 Jul 2024 03:41:11 +0200 Subject: [PATCH] Write tutorial for MakieTeX.jl and TypstJlyfish.jl --- docs/Project.toml | 14 ++++++++++ docs/make.jl | 9 +++--- docs/source/index.md | 2 ++ docs/source/tutorials/packages.md | 46 +++++++++++++++++++++++++++++++ src/Strings.jl | 2 ++ 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 docs/source/tutorials/packages.md diff --git a/docs/Project.toml b/docs/Project.toml index af6c92f..5b1f239 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,4 +1,18 @@ [deps] +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc" +MakieTeX = "6d554a22-29e7-47bd-aee5-0c5f06619414" +TypstJlyfish = "95e5b356-b122-4883-a78a-3c8c946b7332" + +[compat] +CairoMakie = "0.12.2" +Documenter = "1" +Luxor = "3 - 4" +MakieTeX = "0.4.1" +TypstJlyfish = "0.1.0" + +[extras] +Typstry = "f0ed7684-a786-439e-b1e3-3b82803b501e" diff --git a/docs/make.jl b/docs/make.jl index b655960..7f62900 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -7,7 +7,7 @@ using .DocMeta: setdocmeta! using LaTeXStrings: LaTeXStrings, LaTeXString using Luxor: Drawing, finish, julia_blue, julia_green, julia_purple, julia_red, rect, sethue using Markdown: Markdown, MD -using Typstry: Strings, Commands.preamble +using Typstry: Strings, preamble using .Strings: examples, _show_typst, enclose, join_with, typst_mime using Typstry @@ -20,6 +20,8 @@ const modules = [Typstry] const extensions = ["LaTeXStrings", "Markdown"] const template = joinpath(assets, "template.typ") +pages(folder, names) = uppercasefirst(folder) => map(name -> joinpath(folder, name * ".md"), names) + _setdocmeta!(_module, x) = setdocmeta!(_module, :DocTestSetup, quote using Typstry $x @@ -135,9 +137,8 @@ makedocs(; modules, pages = [ "Home" => "index.md", "Getting Started" => "getting_started.md", - "Tutorials" => ["Interface" => "tutorials/interface.md"], - "Manual" => map(page -> uppercasefirst(page) => joinpath("manual", page * ".md"), - ["strings", "commands", "extensions", "internals"]) + pages("tutorials", ["interface", "packages"]), + pages("manual", ["strings", "commands", "extensions", "internals"]), ], sitename = "Typstry.jl", source = "source" diff --git a/docs/source/index.md b/docs/source/index.md index 683f4ef..b7f24fc 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -108,12 +108,14 @@ typst`compile input.typ output.pdf` - [Labelyst.jl](https://github.com/emanuel-kopp/Labelyst.jl) - [SummaryTables.jl](https://github.com/PumasAI/SummaryTables.jl) - [TypstGenerator.jl](https://github.com/onecalfman/TypstGenerator.jl) +- [TypstJlyFish.jl](https://github.com/andreasKroepelin/TypstJlyfish.jl) - [Typst_jll.jl](https://github.com/JuliaBinaryWrappers/Typst_jll.jl) - Dependency of Typstry.jl ### LaTeX - [Latexify.jl](https://github.com/korsbo/Latexify.jl) +- [LaTeXEntities.jl](https://github.com/JuliaString/LaTeX_Entities.jl) - [LaTeXStrings.jl](https://github.com/JuliaStrings/LaTeXStrings.jl) - [LatexPrint.jl](https://github.com/scheinerman/LatexPrint.jl) - [LibTeXPrintf.jl](https://github.com/JuliaStrings/LibTeXPrintf.jl) diff --git a/docs/source/tutorials/packages.md b/docs/source/tutorials/packages.md new file mode 100644 index 0000000..c7ec434 --- /dev/null +++ b/docs/source/tutorials/packages.md @@ -0,0 +1,46 @@ + +# Packages + +## MakieTeX.jl + +!!! note + This package re-exports [`@typst_str`](@ref) and [`TypstString`](@ref). + +```@setup 1 +using Logging: Debug, Warn, disable_logging +disable_logging(Warn) +``` + +```@repl 1 +using CairoMakie, MakieTeX +disable_logging(Debug) # hide +f = Figure(; size = (100, 100)); +LTeX(f[1, 1], TypstDocument(typst"$1 / x$"); scale = 5); +save("makie_tex.svg", f); +``` + +![MakieTeX.jl](makie_tex.svg) + +## TypstJlyfish.jl + +```````@eval +using Markdown, Typstry +s = preamble * typst""" +#import "@preview/jlyfish:0.1.0": * +#read-julia-output(json("typst_jlyfish.json")) +#jl-pkg("Typstry") +#jl(`using Typstry; typst"$1 / x$"`) +""" +write("typst_jlyfish.typ", s) +Markdown.parse("`````typst\n" * s * "\n`````") +``````` + +```@repl +using TypstJlyfish +TypstJlyfish.compile("typst_jlyfish.typ"; + evaluation_file = "typst_jlyfish.json", + typst_compile_args = "--format=svg" +) +``` + +![TypstJlyfish.jl](typst_jlyfish.svg) diff --git a/src/Strings.jl b/src/Strings.jl index 56ee899..47456a7 100644 --- a/src/Strings.jl +++ b/src/Strings.jl @@ -953,6 +953,8 @@ function show(io::IOContext, ::MIME"text/typst", t::Typst) end show(io::IO, ::MIME"text/typst", t::Union{TypstString, TypstText}) = show_typst(io, t) +import Base: codeunit, isvalid, ncodeunits, nextind, prevind, thisind + # Internals """