Skip to content

Commit b4b5fc9

Browse files
author
Christopher Doris
committed
hack to display altair plots
1 parent 98da46b commit b4b5fc9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/compat/multimedia.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ function pyshow_rule_mimebundle(io::IO, mime::String, x::Py)
3434
else
3535
data = ans[mime]
3636
end
37-
write(io, pyconvert(Union{String,Vector{UInt8}}, data))
37+
data = pyconvert(Union{String,Vector{UInt8}}, data)
38+
if mime == "text/html"
39+
data = String(data)
40+
if occursin("altair-viz-", data) && occursin("document.currentScript.previousElementSibling", data)
41+
# unsatisfactory hack to get altair plots to display properly in pluto
42+
# TODO: fix this upstream (in altair or pluto??)
43+
data = replace(data, "document.currentScript.previousElementSibling" => "((document.currentScript || {}).previousElementSibling || {})")
44+
end
45+
end
46+
write(io, data)
3847
return true
3948
catch exc
4049
if exc isa PyException

0 commit comments

Comments
 (0)