From a38bb2ec9513ba6af32c085454225ee9ce83ef08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Sat, 23 Nov 2024 15:31:31 +0100 Subject: [PATCH] fixes for Vega MIME --- src/Visualization.jl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Visualization.jl b/src/Visualization.jl index 8613a88c..5bccbdc4 100644 --- a/src/Visualization.jl +++ b/src/Visualization.jl @@ -30,15 +30,13 @@ function graph_representation(tn::AbstractTensorNetwork) return tn, graph, tensormap, hypermap, hypernodes, ghostnodes end -# TODO use `Base.ENV["VSCODE_PID"]` to detect if running in vscode notebook -# Base.show(io::IO, ::MIME"text/html", @nospecialize(tn::AbstractTensorNetwork)) = draw(io, tn) -# Base.show(io::IO, ::MIME"juliavscode/html", @nospecialize(tn::AbstractTensorNetwork)) = draw(io, tn) - -for v in ["application/vnd.vegalite.v3+json", "application/vnd.vegalite.v4+json", "application/vnd.vegalite.v5+json"] - @eval Base.Multimedia.istextmime(::MIME{$(Symbol(v))}) = true +# TODO use `Base.ENV["VSCODE_PID"]` to detect if running in vscode notebook? +# TODO move this to VSCodeServer.jl +function Base.Multimedia.istextmime(::MIME"application/vnd.vega.v5+json") + return true end -Base.show(io::IO, ::MIME"application/vnd.vegalite.v5+json", @nospecialize(tn::AbstractTensorNetwork)) = draw(io, tn) +Base.show(io::IO, ::MIME"application/vnd.vega.v5+json", @nospecialize(tn::AbstractTensorNetwork)) = draw(io, tn) function draw(io::IO, @nospecialize(tn::AbstractTensorNetwork)) tn, graph, tensormap, hypermap, hypernodes, ghostnodes = graph_representation(tn) hypermap = Dict(Iterators.flatten([[i => v for i in k] for (k, v) in hypermap]))