jsvine / notebookjs

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

KaTeX parsing #8

Closed H-Plus-Time closed 5 years ago

H-Plus-Time commented 7 years ago

I've added support for TeX rendering, via the KaTeX library - at the moment this only works in a browser, with the usual proviso that the katex.min.js and auto-render.min.js resources need to be script src'd first (similarly to markdown and ascii_up).

I picked KaTeX over MathJax due to the performance boost, as well as stated goals on the part of KaTeX contributors to modernise the codebase (MathJax on the other hand appears to be in maintenance mode).

H-Plus-Time commented 7 years ago

Commits 057da9c through to d476216 constitute a rewrite for future maintainability purposes (particularly as dependencies start to switch over to the class/modules system).

Additionally, marked, KaTeX and ansi_up should be built into the notebook..min.js builds now.

Let me know what you think :).

jsvine commented 7 years ago

Wow, thanks @H-Plus-Time! This looks like a wonderful contribution. I haven't had time to comb through it carefully, but plan to do so soon.

jsvine commented 7 years ago

Thanks again for this, @H-Plus-Time! The KaTeX addition is great, and I appreciate you bringing the codebase into the class/modules era.

Can you explain more about the reasoning behind baking ansi_up and marked into the minified libraries? Before this change, notebook.min.js was a svelte 7kb. Now, it's 148k. That's no problem if the user is definitely going to use ansi_up and marked, and haven't already imported it. But if they prefer to use a different library for markdown rendering or ANSI coloring, or have already imported those on the page, then this seems like dead weight.

What do you think? Is there a way to use the build system you've implemented without baking in those libraries?

jsvine commented 5 years ago

Thank you for suggesting KaTeX support, @H-Plus-Time. It is now available in v0.4.0, added via https://github.com/jsvine/notebookjs/pull/19.