Printing to string from stream

Perhaps use IOBuffer

https://docs.julialang.org/en/latest/base/io-network/#Base.IOBuffer

io = IOBuffer()
highlight(io, MIME("text/html"), "a = 1+2", Lexers.JuliaLexer)
my_string = String(take!(io))
3 Likes