This is a long post so I'm putting a summary at the start.
1. Leo can provide a very good way for a user to create and edit Juptyer notebooks.
2. The exploratory work for @jupytext files does not provide a proper Leonine experience.
6. There should be a way to show a view of adjacent or nearby nodes so that the user can make sure they work together as intended. Showing a fully rendered view of nodes' Markdown is a desirable bonus to avoid round-tripping to Jupyter.
6. There should be a way to show a view of adjacent or nearby nodes so that the user can make sure they work together as intended. Showing a fully rendered view of nodes' Markdown is a desirable bonus to avoid round-tripping to Jupyter.Thank you Thomas for such a detailed thought.
Of course, I think what you said `round-tripping` may be a problem. It is possible that users will feel a little messy when switching back and forth between Leo and JupyterLab. But I think this problem is not easy to solve. Considering that the return on investment may not be large enough, I am willing to endure this problem. In general, I am quite satisfied with the way I imagine using Jupytext.
I didn't mean that round-tripping could be a problem. I meant that it imposes extra steps, incurs a time delay, and adds distraction. These things get in the way of the work of composing and thinking out a notebook. As an example, here is how I typically develop Sphinx documents, which use ReStructuredText and the rst3 command. I will draft up a partial structure in Leo, then work on certain nodes. From time to time I will look at them with VR3 to catch any RsT syntax errors and make sure that the appearance seems right. Also I find that viewing a rendered view helps me to catch typos and other editorial errors, and even errors in flow and thinking.
There has been a flurry of activity in the last few weeks to add an ability for working with Jupyter notebooks by means of an intermediate file format. That format is provided by the jupytext program.
However, in the rush no one seems to have thought much about what Leo can bring to the table, or why anyone would want to use Leo for this purpose, compared let's say with the Jupyter plugin for Visual Studio Code, which seems very good and very readable to me.
For those who don't know yet, a Jupyter notebook's file format is JSON. JSON was designed to interchange data, including program structures. It was not designed for documentation or readability.
Any markup such as Leo's sentinels that are needed to support structure or other Leo features are hidden from the user. There's hardly any visual clutter. IMO this is a crucial feature that Leo offers. It makes writing code to save and restore outlines and external files very complicated, but the user doesn't need to know about that.
Leo is not nearly as capable in supporting writing and documentation.
The Leonine Way
------------------
1. Leo should present a view of a Jupyter notebook file to the user without sentinels or visual clutter, just like it does with other external file types.
2. Leo should be able to recreate the file's structure on reloading, or at least a close approximation to it.
3. Code cells should be syntax-highlighted and preferably able to be at least syntax-checkable.
4. Code execution would be a bonus but not required.
5. The user should need to know a minimum of special forms such as directives or other special markup features, and if there are any they should have a form similar to other Leo forms.
6. There should be a way to show a view of adjacent or nearby nodes so that the user can make sure they work together as intended. Showing a fully rendered view of nodes' Markdown is a desirable bonus to avoid round-tripping to Jupyter.
7. There should be an easy way to extend the file handling and rendering capabilities to use other programming languages besides Python.
6. The process of converting, importing, and exporting the files should be invisible to the user, just as for any other external file that Leo currently supports.
Hi,
There has been a flurry of activity in the last few weeks to add an ability for working with Jupyter notebooks by means of an intermediate file format. That format is provided by the JupyText program. However, in the rush no one seems to have thought much about what Leo can bring to the table, or why anyone would want to use Leo for this purpose, compared let's say with the Jupyter plugin for Visual Studio Code, which seems very good and very readable to me.
[...]
I have enjoyed this thread pretty much, as I was one of the first advocates of a combination of the features of Jupyter/IPython regarding interactivity and Leo regarding a self-referential document tree programmable inside itself. So much that I created my own outliner, Grafoscopio, in Pharo Smalltalk as I have told before. My response would be related with how those combinations and alternatives beyond Jupyter (but in "conversations"/inspirations with it) can happen in other tech stacks and communities, with some links for those who arrive at the conversation newly or what to go deeper into what those other technologies offer to get inspiration and crosspollination over here.
As a teaser, here is a screenshot of an Jupyter notebook (at the
rigth), side by side with the importer that is being ran inside a
Lepiter [1] notebook (at the left), inside the Glamorous
Toolkit[1a] environment, powered by Pharo[1b].

[1]
https://lepiter.io/feenk/introducing-lepiter--knowledge-management--e2p6apqsz5npq7m4xte0kkywn/
[1a] https://gtoolkit.com/
[1b] https://pharo.org/
It is interesting to see how interactive notebooks are evolving
in several languages and environments, with Jupyter being the defacto
standard that other communities try to connect with or overcome,
with new designs and possibilities. Some are single language
notebooks, like Elixir's Live Book[2], Clojure's Clerk[2a] or even
my own Pharo's Grafoscopio that try to showcase advantages of
embracing the features of those particular computer
languages/environments. Others are multilingual, like Lepiter or
Nextjournal[2c], that support Jupyter import and Python coding,
while being build in other core technology stack to introduce
features like malleability[3] or real time collaboration. In the
same vein, I wonder how Leo could bring a new writing experience
to interactive documents, beyond reading/writing compatibility
with Jupyter?
[2] https://livebook.dev/
[2a] https://clerk.vision/
[2b] https://mutabit.com/grafoscopio/en.html
[2c] https://nextjournal.com/
[3] https://malleable.systems/
For those who don't know yet, a Jupyter notebook's file format is JSON. JSON was designed to interchange data, including program structures. It was not designed for documentation or readability. Jupyter notebooks contain a sequence of "cells" - basically nodes - that are either Markdown text or code cells. There is no other structure. Jupytext's contribution is to flatten the nested JSON data structure to a flat text format with what amounts to sentinels - each line is commented out, and there are a few specially-formatted comments. One of these special comment lines marks the start of a Markdown cell, and another marks the start of a Python cell.
Leo is very strong in these areas:
[...]
The usage of JSON for document storage, while understandable (in
Jupyter and Lepiter, for example), is unfortunate and I like the
path we followed regarding human/diff friendly formats that we
explored with Grafoscopio (using STON[4] with embedded Markdown
inside, at the beginning), Live Book (with their own Markdown
variant --yes another one!), Clerk, that is just plain Clojure
code in a namespace. Since the launching of Lepiter in 2021, we
have been migrating Grafoscopio from "plain" Pharo to
GToolkit/Lepiter, and I choose a Markdeep[4a] with extended
metadata. This allowed us to exchange and publish data stories
like this[4b] or this[4c], with advantages over all other formats,
particularly ipynb notebooks as the explained here[4d]. If you see
the source code of [4b] or [4c], it's just a web renderable
Markdown variant (another one!, closer to the original) inside
HTML divs with STON metadata in them.
[4] https://github.com/svenvc/ston/
[4a] https://casual-effects.com/markdeep/
[4b]
https://mutabit.com/repos.fossil/gig/doc/trunk/wiki/en/gig-portable-wiki--1apbv.md.html
[4c]
https://mutabit.com/repos.fossil/malleable-systems/doc/trunk/wiki/en/malleable-systems-wiki--23fm1.md.html
[4d]
https://lists.pharo.org/empathy/thread/RJ6RKBL2UCG6RURFEW7L3YLZLYMPYAVR?hash=4QVSF767ZW2ZIICNU4KIJR4DOW6IZEUA#4QVSF767ZW2ZIICNU4KIJR4DOW6IZEUA
Leo is not nearly as capable in supporting writing and documentation. That's because even though structure is important, it's also important to be able to see and edit the flow of the document from node to node and how nearby parts work together. An example is creating documentation using the rst3 command and Sphinx. The mechanics of this process are excellent but doing editing beyond the node level requires a lot of mental effort and trial runs with Sphinx. The Viewrendered3 plugin is designed to help with this problem by letting the user view an entire subtree.
Jupyter notebooks are serial combinations of documentation and code. Basically they are a limited form of "literate programming". The code cells are usually small enough that they don't need to be structured. They are displayed by a Jupyter-viewing program in a clean, very readable way.
The Jupytext work over the last few weeks presents the user with a direct view of the Jupytext-formatted file, sentinels, embedded comments, and all. A user has to hand-edit the file while being distracted by the extra markup and not being able to see the flow of the parts one into another. Yes, parts can be moved around and navigated to using the outline, but the editing experience is inferior. There is also no syntax highlighting for code nodes - since the code is all commented out - nor can even rudimentary syntax checks be carried out. The appearance of the document as it would be viewed in a Jupyter program - well, it is unknown until the file is saved to the .ipynb form and reloaded into Jupyter.
[...]
The advancements in editing and viewing Jupytext inside Leo are
pretty interesting, despite not using Python/Leo actively myself,
after me departing to the Pharo/Smalltalks realm. I have seen some
screenshots in this thread and it is closer to a dreamed
interactive programmable outliner I had years ago. I wonder if a
video could transmit better the interactive usage experience for
the Leo + Jupyter combination, particularly regarding the notebook
modification, writing, calculation and plotting inside it. While
Leo was not thought for interactive computing/writing/live-coding,
I think that its ideas have a lot to offer there.
Kudos to the community for this exploration.
Offray
Thanks for the update. @jupytext should open the door to better cooperation between tools.
Edward