How to set MIME encoding in Julia?

Viewed 297

I am trying to call the following show function which has the signature: function show(io::IO, ::MIME"text/plain", holder::Int). What do I need to do with the 2nd argument such that I can call this function? I am unsure what "::MIME"text/plain" is asking for.

1 Answers

All of

julia> show(stdout, "text/plain", "hi")
"hi"
julia> show(stdout, MIME("text/plain"), "hi")
"hi"
julia> show(stdout, MIME"text/plain"(), "hi")
"hi"

work. The first one is because there's an overload that passes the second argument to the MIME constructor. The two latter ones are just different ways of constructing the mime type:

julia> MIME("text/plain") == MIME"text/plain"()
true

julia> MIME"text/plain"()
MIME type text/plain
Related