Skip to content

Commit 1637fcd

Browse files
committed
Update Base.display(::InlineDisplay, ...) methods to use display_data()
1 parent 4626422 commit 1637fcd

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/inline.jl

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ function limitstringmime(mime::MIME, x)
5454
return String(take!(buf))
5555
end
5656

57-
for mime in ipy_mime
57+
for mimestr in ipy_mime
58+
M = MIME{Symbol(mimestr)}
5859
@eval begin
59-
function display(d::InlineDisplay, ::MIME{Symbol($mime)}, x)
60-
send_ipython(publish[],
61-
msg_pub(execute_msg, "display_data",
62-
Dict(
63-
"metadata" => metadata(x), # optional
64-
"data" => Dict($mime => limitstringmime(MIME($mime), x)))))
60+
function display(d::InlineDisplay, ::$M, x)
61+
s = limitstringmime($M(), x)
62+
m = get(metadata(x), $mimestr, Dict())
63+
display_data($M(), s, m)
6564
end
66-
displayable(d::InlineDisplay, ::MIME{Symbol($mime)}) = true
65+
displayable(d::InlineDisplay, ::$M) = true
6766
end
6867
end
6968

@@ -76,26 +75,21 @@ display(d::InlineDisplay, m::MIME"text/javascript", x) = display(d, MIME("applic
7675
# If the user explicitly calls display("foo/bar", x), we send
7776
# the display message, also sending text/plain for text data.
7877
displayable(d::InlineDisplay, M::MIME) = istextmime(M)
78+
7979
function display(d::InlineDisplay, M::MIME, x)
8080
sx = limitstringmime(M, x)
8181
d = Dict(string(M) => sx)
8282
if istextmime(M)
8383
d["text/plain"] = sx # directly show text data, e.g. text/csv
8484
end
85-
send_ipython(publish[],
86-
msg_pub(execute_msg, "display_data",
87-
Dict("metadata" => metadata(x), # optional
88-
"data" => d)))
85+
display_data(d, metadata(x))
8986
end
9087

9188
# override display to send IPython a dictionary of all supported
9289
# output types, so that IPython can choose what to display.
9390
function display(d::InlineDisplay, x)
9491
undisplay(x) # dequeue previous redisplay(x)
95-
send_ipython(publish[],
96-
msg_pub(execute_msg, "display_data",
97-
Dict("metadata" => metadata(x), # optional
98-
"data" => display_dict(x))))
92+
display_data(display_dict(x), metadata(x))
9993
end
10094

10195
# we overload redisplay(d, x) to add x to a queue of objects to display,

0 commit comments

Comments
 (0)