How to get a markdown repr of an object? (MIME type fallbacks)

I believe showable is meant for cases like this, but it is not perfect since it just checks that the method exist for the given argument and mime type. It will for example fail when someone defines a fallback like

function Base.show(io::IO, ::MIME, x::MyType)
    error("MyType does not support this MIME type")
end

see e.g. https://github.com/JuliaLang/IJulia.jl/issues/835.

1 Like