Many thanks for all your excitement and kind words. I share that 
excitement. @jupytext may be Leo's most important addition since @clean.


If I understand correctly, the remaining rough edges involve creating 
.ipynb files and their corresponding @jupytext nodes.


*Creating .ipynb files in Jupyter*


We can sidestep problems creating .ipynb files as follows:


- Create the x.ipynb file *in Jupyter*.

- Create the @jupytext x.ipynb node in Leo, *without* saving the outline.

- Populate the @jupytext x.ipynb node using refresh-from-disk.


refresh-from-disk will put the entire file into the root @jupytext node. 
You can then create organizer nodes as you like. Saving the outline will 
update x.ipynb. After that, everything will just work.


*Creating .ipynb files in Leo*


Naturally, we want to create .ipynb files safely from within Leo. Imo, Leo 
should write @jupytext x.ipynb as follows. There are two cases to consider:


*Case 1: x.ipynb exists*


This is the easy case. Just create an *empty *@jupytext x.ipynb node. As 
usual, when you save the outline Leo will warn that the corresponding 
.ipynb file exists. You should *not* overwrite the file but instead use 
refresh-from-disk. 


*Case 2: x.ipynb does not exist*


When x.ipynb does not exist, it's slightly more challenging for Leo to 
create a valid .ipynb file. There are two sub-cases to consider:


1. If the @jupytext tree is *completely *empty, Leo should create a valid 
.ipynb file. That is, the file should contain nothing but the *Jupyter 
prefix*. Rather than hard-coding this prefix, Leo should use the contents 
of *@data jupyter-prefix*.


2. Otherwise (the @jupytext tree contains text), Leo should write the 
@jupytext tree, possibly with a warning that creating an .ipynb file by 
hand isn't a good idea.


*Summary*


- Creating .ipynb files in Jupyter just works now.

- Leo can easily create valid .ipynb files from *empty *@jupytext trees.

- Leonistas should avoid creating .ipynb files by hand, that is, by saving 
non-empty @jupytext trees.


I welcome all your comments and suggestions.


Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/b897fcbc-4492-4101-a6ca-62d02d49f669n%40googlegroups.com.

Reply via email to