How to render Jupyter Notebooks on Gitea - Blog

Thu Apr 28, 2022 by HarvsG


This is a companion discussion topic for the original entry at https://blog.gitea.io/2022/04/how-to-render-jupyter-notebooks-on-gitea/
1 Like

Hi, this blog really helps me!
But there’s something different with my situation.

In app.ini, according to “None” appears when converting to HTML with “full” template #1652, full option already deprecated in jupyter/nbconvert for several versions. So RENDER_COMMAND shuold be like this:

RENDER_COMMAND = "jupyter nbconvert --stdout --to html --template classic"

And another thing, I added the jupyter.less to the site, the page shows well, but <html> and <head> tags still shows in the page. I have no idea about how can I handle this. Is there any way to correctly shows them or just remove them if they are useless?

You should remove HTML, HEAD tags from you output. Or you can wait Allow render HTML with css/js external links by lunny · Pull Request #19017 · go-gitea/gitea · GitHub which introduce iframe to render the output.

1 Like

Thanks for helping.
According to your guide, I finally found out the solution to prevent this. in jupyter nbconvert, when using basic template, there will be no <head> or other tags in the output. Only have div tags in it. So after I changing it, the jupyter notebooks file rendering very well in my page. The config in app.ini should be like this:

RENDER_COMMAND = "jupyter nbconvert --stdout --to html --template basic"

Hello Lunny,

thank you for to detailed post.
Do you know how to customize Gitea further, such that the mathematical equations are also drawn by MathJax which are created automatically by Jupyter?

This was already discussed here (Katex/MathJax render) but the focus lies on Pandoc and Katex. Therefore that discussion is only a bit helpful for the Jupyter/MathJax case.

Anyhow if you know how to do it, do you mind updating your blog post. It might be helpful for a lot of people (including me).

Best Regards
Gilles