diff --git a/lucid/scratch/web/observable.py b/lucid/scratch/web/observable.py new file mode 100644 index 00000000..1f7e40c1 --- /dev/null +++ b/lucid/scratch/web/observable.py @@ -0,0 +1,86 @@ +import json +from lucid.misc.io.showing import _display_html + +def renderObservable(url, cells=None, data=None): + """Display observable notebook cells in iPython. + + Args: + url: url fragment to observable notebook. ex: '@observablehq/downloading-and-embedding-notebooks' + cells: an array of strings for the names of cells you want to render. ex: ['viewof stage', 'viewof x'] + data: a dictionary of variables that you'd like to overwrite. ex: {'x': 200, 'width': 500} + """ + + head = """ +
+
+ source +
+ " + + _display_html( + head + runtimeImport + notebookImport + cellsSerialized + dataSerialized + code + foot + )