I want to have different Base.show
representations for a struct when I am on REPL and when I am on Pluto by invoking the same code. Is there a more specialized ::MIME
I can use for this purpose, other than ::MIME"text/plain"
?
Example
Define a simple struct in a dummy package:
module PlutoReplShow
export Alpha
struct Alpha
vec1::Vector{Int}
vec2::Vector{Int}
vec3::Vector{Int}
end
# this expression must target only the REPL and not Pluto
Base.show(io::IO, ::MIME"text/plain", a::Alpha) = print(io,"Alpha($(a.vec1[1])...,$(a.vec2[1])..., $(a.vec3[1])...)")
end
This code is later invoked by both the REPL and Pluto.
The defined Base.show
influences both REPL and Pluto, but I would like to target only the REPL.
So, for the REPL it works fine:
julia> al = Alpha(1:10, 1:10:100, 2:-1:-30)
Alpha(1...,1..., 2...)
but not for Pluto: