Dear All, Pluto expert users and/or developers, I wonder is there would be an easy way to import and existing Julia (.jl) file into Pluto, without having to manually create new cells and do cut and paste (with begin end insertions at some times…) ?
I know I am lazy, but may be it could be usefull, eg for converting from plan JL and/or IJulia notebooks? (as of now, I am wondering which technology is most suitable for which kind of tasks)
This includes results of the file, but does not enable to edit interactively as Pluto’s goal. I would like to have the text of the file inside cell(s) of Pluto, so to continue to develop, or modify parameters …
By the way, the work is equally tedious when covertiing plain julia/REPL file to IJUlia notebook, except that you can start by having only on giant cell containing everyting, then split it accordingly to desires.
With Pluto there is the additional chore to wrap each new cell with begin/end, so to be sure that the system work. An automatic way of doing this (or, an automatic cleaner that would remove begin-end (or let-end without vars) when there is no error generated for the cell) could be useful. But I understand the case for it would be very narrow , so I would guess would not fit with Pluto development (@fonsp) process ?
As my utility did work for me, I marked it as Solution, and then did no further work.
I just now additionally commented on the GitHub thread mentioned above (should have done that at that time, sorry).
With this functionality, you can just drag your jl file into a Pluto notebook and its content is pasted to a Pluto cell.
For optimal usage into Pluto, you probably need to do some manual modifications like splitting into multiple cells.
I do not know of such a script, but it should be easy to prototype one, peeling out the # annotations. Just an interrogation to think about, if using the bind facilities of PlutoUI, then should probably keep it?
@jdad, thanks for your nice prototype script which was written in 100% Julia (with no packages used)! As a Windows user trying to stay away as much as possible from the DOS terminal, preferred running the script from VS Code by bypassing the command-line input arguments’ logic and jumping straight to around row#82 in the script, defining:
inplace = false
enableoverwrite = true
keepblank = false # this was missing in prototype
inputfile = "C:/Users/jrafa/ex1_Pluto.jl"
outputfile = inputfile * "_out.jl"
The result was a Pluto-clean *.jl file.
Thank you so much!