notebookjs icon indicating copy to clipboard operation
notebookjs copied to clipboard

CLI usage?

Open zmoon opened this issue 3 years ago • 3 comments

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?

zmoon avatar Mar 03 '22 19:03 zmoon

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

jsvine avatar Mar 04 '22 16:03 jsvine

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

surajsharma avatar Jan 28 '24 09:01 surajsharma

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.

jsvine avatar Mar 02 '24 14:03 jsvine