Inspired by the discussions in the PlantUML thread 
<https://groups.google.com/forum/#!topic/leo-editor/hNkQG5n6X6M>, the 
following short script is a prototype for @jupyter, to be part of the 
viewrendered plugin:

import nbformat
from traitlets.config import Config
from nbconvert import HTMLExporter
from urllib.request import urlopen
# Read the .pynb file, and convert it into html text, in body.
url = 'http://jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb'
s = urlopen(url).read().decode()
nb = nbformat.reads(s, as_version=4)
e = HTMLExporter()
(body, resources) = e.from_notebook_node(nb)
# Now create an @html node.
p = c.p.insertAfter()
p.h = '@html'
p.b = body
c.selectPosition(p)
c.redraw()

This is my kind of prototype--less than 20 lines of code.  Try it, viewing 
the new node with the viewrendered plugin.

The guts of this code comes from this page about nbconvert 
<https://nbconvert.readthedocs.io/en/latest/nbconvert_library.html#Quick-overview>.
 
This page has other goodies...

It will be straightforward to convert this to @jupyter support in the VR 
plugin. The body of @jupyter should specify the source, either a url or a 
local file.  The VR plugin will generate the html and show it in the VR 
pane.

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 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