This tool parses Jupyter notebooks for posting to the QNN blog. It is based off of the work from this repository.
There are two steps:
- Use qnn_nb2wp to convert the Jupyter notebook to html and separate image files.
- Upload the html and image files as a QNN blog post.
For a minimal html conversion simply follow these steps:
- Download
qnn_nb2wp.py
as well asstyle.css
from the QNN Github here and put them into the same folder as your Jupyter notebook - In python run the following code with the
img_prefix
variable being the prefix of the image filenames andimg_url_prefix
being the prefix to the media directory of the blog post on the QNN blog (something likehttps://qnn.mit.edu/wordpress/wp-content/uploads/2024/08/
from qnn_nb2wp import *
qnn_nb2wp('name_of_notebook.ipynb', img_prefix='prefix', img_url_prefix='url-prefix')
This results in a folder of the same name as the .ipynb
file with an html file and a directory of exported images. Next we will tackle posting this to the blog.
After the export tool has run, you now just need to export the html output to the blog. To do this:
- Create a new post
- Go to Text edit mode
- Copy and paste the html text output into the text edit window of the WordPress post
- Upload all images to the media folder of the blog
Now you should be able to preview and post the blog as usual. Done!
The following changes have been made to update the code from the original tool.
- The nbconvert commands around the HTML template name specification were updated to the new syntax (this was changed from the original version).
- A new
img_prefix
input was added to specify the image prefix name to prevent naming conflicts on the QNN blog media folder.