-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support display of arbitrary textual MIME types in REPL #19993
Conversation
… error if show(io, MIME, x) is not defined during display
Thanks!
Interestingly, |
Seems like we should support a 2-arg version show(m::MIME, x) = show(STDOUT, m, x)
show(m::AbstractString, x) = show(MIME(m), x) |
(I fixed the IJulia inconsistency in JuliaLang/IJulia.jl@8f92249, thanks.) |
Should be ready to merge. |
@StefanKarpinski, yes, I ran into this in JuliaPy/PyPlot.jl#281 as well. I'm thinking that maybe the REPL display should override |
So this change breaks import Base.Multimedia: @try_display, xdisplayable
function display(p::Context)
displays = Base.Multimedia.displays
for i = length(displays):-1:1
m = default_mime()
if xdisplayable(displays[i], m, p)
@try_display return display(displays[i], m, p)
end
if xdisplayable(displays[i], p)
@try_display return display(displays[i], p)
end
end
invoke(display, Tuple{Any}, p)
end How to you recommend doing this with this change? |
@tlnagy, you shouldn't be overriding The only reason to override |
I'm not sure why we have that in the Compose codebase. It looks like Daniel added that 3 years ago. I'll try and strip it out and see what happens. |
By default, the REPL displays objects in text/plain format, but if you explicitly call
display("text/foo", x)
then this PR allows it to print.e.g. it was noted by @cstjean on discourse that the inability to do
display("text/csv", matrix)
was annoying. This now works.Also as noted by @cstjean, the exception thrown by
display("text/foo", x)
was somewhat confusing if the problem is the lack of ashow
method fortext/foo
. After this PR, it throws the expectedMethodError
forshow
(rather than aMethodError
fordisplay
).