TypstJlyfish.jl icon indicating copy to clipboard operation
TypstJlyfish.jl copied to clipboard

How do I display a multiline Julia `String`?

Open kapple19 opened this issue 6 months ago • 6 comments

Hi, I'm absolutely loving this combination of Julia and Typst, thank you for this interface, it's been working amazingly for me so far.

I'm currently trying to display print_tree output from an AbstractTrees definition, here's a MWE.

using AbstractTrees

abstract type MyType end
struct A <: MyType end
abstract type B <: MyType end
struct C <: B end

# May need `using InteractiveUtils`
AbstractTrees.children(::Type{T}) where {T <: MyType} = subtypes(T)

print_tree(MyType)

The output is the monospaced text:

MyType
├─ A
└─ B
   └─ C

which I would like to display in my Typst PDF.

Currently the many different things I've tried only show MyType\n or MyType or MyTypen or "MyType\n". I've also tried grabbing the printed tree text using a buffer = IOBuffer() with print_tree(buffer, MyType) and then treetext = buffer |> take! |> String but then I don't know what to do with treetext. Converting to TypstString doesn't work.

Is there a way for me to display the monospaced multiline output without going so far as to create a new text file for the Typst document to read from?

kapple19 avatar Sep 04 '24 01:09 kapple19