-
Notifications
You must be signed in to change notification settings - Fork 72
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 for Pluto.jl #90
Comments
Good idea. At the moment Jupyter is hard-wired in, so if I can work out the equivalent runes for Pluto it should be easy to add. |
First of all, thank you so much for reaching out to me! I like Luxor and I think it would be super fun to work with it inside Pluto! I do have solution, but it would lead to (minor) breaking changes to the behavior inside Jupyter, that's why I didn't suggest it before. As an example of what I mean, here's the current macro svg(body, width=600, height=600, fname="luxor-drawing-$(Dates.format(Dates.now(), "HHMMSS_s")).svg")
quote
local lfname = _add_ext($(esc(fname)), :svg)
Drawing($width, $height, lfname)
origin()
background("white")
sethue("black")
$(esc(body))
finish()
preview()
end
end Luxor uses an internal state, Instead, the function preview()
return CURRENTDRAWING[1]
end The goal here is to use Julia's built-in display system to do the OS & environment switches - it would still give rich output on environments that support it, because any environment that runs an However, this would lead to two changes:
function Base.show(io::IO, ::MIME"text/plain", d::Drawing)
returnvalue = d.filename
if Sys.isapple()
run(`open $(returnvalue)`)
elseif Sys.iswindows()
cmd = get(ENV, "COMSPEC", "cmd")
run(`$(ENV["COMSPEC"]) /c start $(returnvalue)`)
elseif Sys.isunix()
run(`xdg-open $(returnvalue)`)
end
print(io, returnvalue)
end Note: one could argue that 1. has the silver lining of making the Julia display system more uniform and easier to understand. For example, why does the Jupyter cell @svg begin ... end
@svg begin ... end show two drawings, while sqrt(1)
sqrt(2) only shows the second result? So that was my breaking suggestion, and I completely understand that this might not be what we want, and that there were deliberate design choices for the current display system. I also see that you just released Let me know what you think! I can also help to figure out a non-breaking fix that just adds an extra check to -fonsi |
Thanks so much! I'll study this and see what I think. |
OK, this is looking good! (This area of Luxor is very old, predating Juno etc, so it's good to have a rework...) In fact Pluto is working perfectly so far: I have two problems - first to include the SVG cleaning code somewhere, which was here:
which is basically needed to avoid the SVG namespace errors when two or more SVG files are stored in the same document. (Eg And second, to work out why the images in Juno and Jupyter are displayed in the right place and also opened in the Finder as well... (two previews are not always what you want...:)). The current master of Luxor.jl has these updates... |
Wow that's looking great! You can put the SVG cleaning at the start of |
Have a look at #91 |
Thanks to @fonsp, now supported... :) |
MWE (from the docs):
and we get:
The
@png
macro orpreview()
also don't seem to work right now. But that might be an issue related to the Pluto.jl backend (although it supports pngs from Images.jl - see fonsp/Pluto.jl#60)The text was updated successfully, but these errors were encountered: