-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
TypstCommand can be used with run to to do most typst tasks. However, for typst query you rather want to fetch the output as well.
julia> using Typstry
julia> write("test.typ", "#figure[]<fig>")
16
julia> run(TypstCommand(["query", "test.typ", "<fig>"]));
[{"func":"figure","body":{"func":"sequence","children":[]},"placement":null,"scope":"column","caption":null,"kind":"image","supplement":{"func":"text","text":"Figure"},"numbering":"1","gap":"0.65em","outlined":true,"counter":"counter(figure.where(kind: image))","label":"<fig>"}]
julia> read(TypstCommand(["query", "test.typ", "<fig>"]), String);
ERROR: MethodError: no method matching read(::TypstCommand, ::Type{String})
At the moment a possible workaround is to dip into some internals.
julia> t = TypstCommand(["query", "test.typ", "<fig>"])
typst`query test.typ <fig>`
julia> read(`$(t.compiler) $(t.parameters)`, String)
"[{\"func\":\"figure\",\"body\":{\"func\":\"sequence\",\"children\":[]},\"placement\":null,\"scope\":\"column\",\"caption\":null,\"kind\":\"image\",\"supplement\":{\"func\":\"text\",\"text\":\"Figure\"},\"numbering\":\"1\",\"gap\":\"0.65em\",\"outlined\":true,\"counter\":\"counter(figure.where(kind: image))\",\"label\":\"<fig>\"}]\n"
Metadata
Metadata
Assignees
Labels
No labels