RSS notebook - 1/1 Blog notebook (8) sphinx (13)

notebook - 1/1

AttributeError: module ‘jinja2’ has no attribute ‘Markup


The notebook conversion fails again due to the following error:


Gallery of notebook


The module sphinx-gallery became quite popular. I discovered that sphinx-nbexamples was doing the same. I integrated the first one into pyquickhelper but I did something different for the second as I already had some custom logic to handle notebooks. get_thumbnail <pyquickhelper.helpgen.ipythonhelper.notebook_runner.NotebookRunner.get_thumbnail() which creates a thumbnail by getting the last image if there is one or the last result output cell. The module uses matploblib to builds an image with text results. You can check the results at Notebook Gallery.


Open the notebook from a virtual environment


On Windows, I did not check on Linux, the short cut jupyter-notebook.exe is not present in the virtual environment. Here is a simple python program to launch the notebook server from the virtual environement.


Export a notebook with no code


Sometimes, you just want to remove all codes from your report. You can just reasd the json of a notebook and remove all codes by yourself or you can add an extra preprocessor which removes all the code in a notebook. We do something similar to this example. First we create a preprocessor:


Why do I see invered question in a notebook converted into PDF?


The function process_notebooks still uses the executable pdflatex and not xetex which can handle inline unicode characters. That’s why they are replaced by ¿ by function post_process_latex.


Convert a notebook into slides


I thought it would be easy to convert a notebook into slides. I would just have to execute nbconvert. I went through two issues. The first one came from reveal.js. My first tries did not work. I decided to take the version included in the module sphinxjp.themes.revealjs and I also updated the output of nbconvert to remove external links as much as possible.


Add a custom menu to the notebook


The function add_notebook_menu add HTML and Javascript to the notebook to create links to all sections in the notebook:



Visualize differences between two files in a notebook


It is now possible to visualize the differences between two files directly from a notebook:


RSS notebook - 1/1 2019-11 (1) 2020-08 (2) 2020-09 (1) 2021-01 (1) 2022-03 (1)