Skip to content

Commit

Permalink
Write tutorial for MakieTeX.jl and TypstJlyfish.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Jul 13, 2024
1 parent 26a0047 commit 2460795
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
14 changes: 14 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 5 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
46 changes: 46 additions & 0 deletions docs/source/tutorials/packages.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions src/Strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down

0 comments on commit 2460795

Please sign in to comment.