jsvine / notebookjs

Render Jupyter/IPython notebooks on the fly, in the browser. (Or on the command line, if you'd like.)
MIT License
274 stars 48 forks source link

CLI usage? #39

Open zmoon opened 2 years ago

zmoon commented 2 years ago

I am wondering about CLI usage. Some things in the repo make it sound like there is or was CLI support to render and open notebook in browser, but I couldn't figure out how to do that with npx. Is it possible?

jsvine commented 2 years ago

Hi @zmoon, and thanks for your interest in this library. When I wrote the main part of the code, npx wasn't on my radar, unfortunately. I imagine that it'd be possible to add that functionality, and I'd welcome a PR that provides it. In the meantime, you can see an example of a small script that provides command-line rendering here: https://github.com/jsvine/notebookjs/blob/master/bin/cli-render.js

... the usage of which would be: node cli-render.js < my-notebook.ipynb > my-notebook.html

surajsharma commented 8 months ago

... the usage of which would be: node cli-render.js < my-notebook.ipynb > my-notebook.html

unfortunately this will not work, you can try though.

jsvine commented 7 months ago

unfortunately this will not work

Thanks, @surajsharma — it appears you are correct. The JavaScript ecosystem has evolved quite a bit since that code was written, and it now throws an Error [ERR_REQUIRE_ESM]: require() of ES Module error on this line of notebook.js:

var lib = root.ansi_up || (typeof require === "function" && require("ansi_up"));

Unfortunately, although I see the benefits of updating this library for modern JavaScript, it is not enormously high on my todo list. If anyone would like to take a crack at it, I'd be happy to discuss.