On Sun, Oct 20, 2024 at 11:49 PM George Zipperlen <
[email protected]> wrote:

There are two issue that I have with iPython / Jupyter notebooks where Leo
> can be of immense help:
>
> The notebooks are giant JSON blobs...
>
...

> Jupyter itself is a horrible code editor...
>
...

> In my world there is no single-language solution, and both code and data
> need version control.
>
> Summary: I support Leo / JuPyteR integration, whether it is hosted by
> Jupyter or by Leo.
>

Many thanks, George, for this request. You've given me a juicy new project!

There are at least two ways forward. None requires heroic solutions such as
running Leo within Jupyter or vice versa.

1*: Make Jupyter a client of Leo's existing server*

leoserver.py would be enhanced to provide Jupyter-specific requests. Maybe
something like 'convert-ipynb-to-outline'. Details are fuzzy :-) However,
there's probably a simpler way:

2: *Enhance Leo's existing support for detecting changed external files*

Leo will *already* detect changes to any external file given by "@file" or
"@clean" nodes. So Leo should detect changes in .ipynb files, provided they
occur in Leo's outline.

With jupytext <https://jupytext.readthedocs.io/en/latest/>as an
inspiration, Leo might *pair .ipynb with corresponding outline nodes*:

- Update the paired outline node when the corresponding .ipynb file changes.
- Write the paired .ipynb file when the corresponding outline node changes.

The details of pairing .ipynb files with outline nodes are fuzzy. But
surely this pairing is possible.

I assume that Jupyter can update .ipynb files when they change externally.

*Maintaining outline structure*

Pairing .ipynb files with "@clean" nodes will preserve outline structure
auto-magically. This approach should suffice when sharing files because
there is no way to change outline structure within Jupyter Notebooks!

This issue may need a rethink if Jupyter becomes a client of Leo's server.
For example, Leo could embed *alternate sentinel comments* into the text of
the .ipynb. We definitely do *not* want to inject Leo's existing sentinels!

*Summary*

The simplest way forward would be to *pair *"@clean" nodes with
corresponding .ipynb nodes:

- Update outline nodes when their paired .ipynb files change.
- Write .ipynb files when their paired outline nodes change.

The details of pairing are unclear, but prototyping this approach should
take only a few hours.

I'll investigate making Jupyter a client of leoserver only as a last resort.

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 on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS1wGc3o-ggSGRZn1wt-NSPADt%3D5CM9wB%2Bzy%3DpaD%3Dsv5cQ%40mail.gmail.com.

Reply via email to