Edward,

Thanks for all your work as always. Having a computer experience which brings the best of Jupyter and Leo integration has been a long search in my case and having Leo nodes used as IPython/Jupyter headers is a really good step.... But I think that integration should be otherwise, bringing the interactivity and render capabilities of IPython to the power of Leo programmable self-referential trees. Here is something I wrote 3+ years ago about this idea (without proof-reading and a worse English at that time):

[1] http://mutabit.com/offray/static/blog/output/posts/on-deepness-and-complexity-of-ipython-documents.html

and here is something I wrote a year about how to explore this idea of programmable DOM + Live Interactive nodes on Pharo/Smalltalk instead of python

[2] http://mutabit.com/offray/static/blog/output/posts/grafoscopio-idea-and-initial-progress.html#

I don't think I'm part of the usual suspects, mainly because I don't code (:-P), but I have trying to advocate these ideas to the Leo community since long time ago (without the eloquence or coding abilities to make myself clear), but now seems that is a better time for them. I don't know if a Qt object could be complex enough to render small parts of HTML or code (markup or python) inside a Leo node, but I think that Leo's DOM and computing model its a lot richer that the one in the IPython notebooks, while code completion, live markup and HTML rendering are better in IPython that in Leo. So keeping the Leo outlining experience while giving each node the interactivity of IPython would be a far better interesting approach.

I hope being clearer this time or at least put some ideas to move.

Thanks again,

Offray

On 23/03/16 15:55, Edward K. Ream wrote:
On Wednesday, March 23, 2016 at 6:13:16 AM UTC-5, Edward K. Ream wrote:

> Leo now has two *experimental* commands:
>  import/export-jupyter-notebook
> ...I'm not sure how important these commands will be.

Well, I'm sure now...

*Jupyter can now render any Leo outline!!!*

This means that /right now/ Leo users can get all the cool features of both Leo and Jupyter. Just export /any/ Leo outline to a .ipynb file, and load the file into Jupyter.

*Jupyter is Leo's long-sought rendering engine!

The exported notebook works like the rst3 command!
*
A truly simple hack gives allows you to organize your Leo file as usual, and have the result (in Jupyter) look like what you would get using Leo's rst3 command.

If a 'markdown' node p (a node with @language markdown or @language rest) does /not/ match the regex:
|
'^<[hH][123456]>'
|

then the export code inserts:

|
<hn>p.h</hn>
|

at the start of p.b. n is simply:

|
max(6,1+p.level()-self.root.level)
|

That's it!!!  We get auto-creation of headlines /in the Jupyter notebook./

That's almost all you need to know, but let me explain in detail what happened.

*Improved import code*

The original code just dumped all the "hidden" data into children of the each cell node. Cells were labelled "cell 1", "cell 2", etc.

The overall effect was clumsy and wonky. No wonder I doubted that anything good would come of it.

But today all the "cruft" children gradually went away. For example, 'cell_type' is represented by @language directives. So the only remaining items contain important data, and 'markdown' nodes /never/ have children.

*Improved export code*

The code is now completely independent of the import command. For example, it generates a top-level metadata element if there is no {prefix} node.

Furthermore, the export and import code collaborate to remember Leo headlines. Of course, these are invisible to Jupyter, but the <hn> tags /reproduce/ Leo's headlines in Jupyter.

BTW, the export code has flattened the outline from day 1. At present, the root of the tree isn't exported, but that would be trivial to do. Not sure it's a good idea.

*Summary

*Lot's of incremental improvements have suddenly yield something spectacular. I vividly remember the shock when I saw Leo headlines in /imported/ code. I started to reorganize the flat nodes of a real notebook: 04_Neural_Networks.ipynb. All of a sudden, it's organization became clear!

Folks, this is an Aha on a par with "webs are outlines in disguise":

1. We can get all of Jupyter's rendering capabilities by exporting an outline to an .ipynb file.

2. The export process automagically produces markdown/Jupyter headlines by default, but this can be over-ridden by placing <h1> ... <h6> anywhere in a 'markdown' node.

3. The importer represents previous cruft directly in cell's body text. Only significant data remains.

4. The exporter will work on /any/ Leo outline.

5. All of Leo's organizational prowess can now be applied to Jupyter notebooks! In particular, the present export code now works much like Leo's rst3 command.

This is really just day one of the project. Bugs may lurk and further improvements may appear. No matter. There is now an /easy/ way to:

- Create Jupyter notebooks in Leo,
- Render Leo outlines using Jupyter.

A great day for Leo. It's time to start playing with Jupyter, if you haven't already. I promise, it will be fun...

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] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to