Send output of show to file

How do I send the output of show to a file? I tried the following with several mime types without success.

julia>   open("file.jl", "w") do io
            show(io, MIME"plain/text", [[1,2],[3,4]])
         end

The second argument of show must be of type MIME, while MIME"type" returns the MIME{Symbol("type")} type (not an instance of that type). To have an instance of MIME, call either MIME("type") or MIME"type"():

show(io, MIME("text/plain"), [[1,2],[3,4]])

(also, not “plain/text”).

1 Like