How to convert Jupyter Notebook to Wordpress suitable HTML

I made a Jupyter notebook this week which will be a great post for my blog. I've already found that you can export this notepad to a simplified HTML format that can be embedded in a web page using this command:

jupyter nbconvert mynotebook.ipynb --to html --template basic

      

However, I would like to change some simple things. For example: now every header ends with a line end character and there is no clear difference between input and output.

On the NBConvert documentation page in Jupyter, I can't find anything about modifying templates ( https://ipython.org/ipython-doc/3/notebook/nbconvert.html ). They only speak

"IPython provides several templates for some of the output formats, and these can be specified with the optional --template argument."

Can I specify my own template? And where can I find the "base" template that I want to customize?

+11


source to share


5 answers


You need to install the following plugin in wordpress: "oEmbed Gist"

Then just follow these steps:



1 / Paste your laptop into your gistub (don't forget to add the .ipynb extension).

2 / Just paste the link to your gist and wordpress will do all the work for you

+15


source


The oEmbed Gist plugin can only be installed if you are a premium Wordpress member. However, inserting

[gist linkToYouGist]



in a wordpress post, will get the job done!

+5


source


For those looking to load HTML into Wordpress (as opposed to embedding it via Gist), you can use the nb2wp tool to convert the notepad to normal HTML, which does not require plugins, CSS, or any scripts. Images will be extracted and latex directives converted to WP latex directives.

The utility does the following:

  • convert .ipynb to HTML using nbconvert using selected template (full, basic or custom)
  • convert your CSS to inline style using the pynliner to make Wordpress respect that style. By default, it replaces the CSS given by nbconvert with a simpler, more convenient style.css that the pynliner can inline.
  • extract inline images (like those generated by Matplotlib) and local images to img directory. You need to download this img directory somewhere and provide a URL prefix for the images.
  • convert latex directives to wordpress.com latex directives.

Then you need to do some manual work:

  • copy and paste the HTML code into the Wordpress HTML editor
  • download image catalog.

This is far from ideal and the result is not very good, but it is a start and an alternative, I think. (disclaimer: I am the author)

+1


source


I made a Wordpress laptop plugin that will work for any url wherever it is! I'll add this publicly to Wordpress soon.

https://www.andrewchallis.co.uk/portfolio/php-nbconvert-a-wordpress-plugin-for-jupyter-notebooks/

It is used in the same way as the gist plugin, except it is called nbconvert

[nbconvert url = 'Www.example.co.uk/path/to/some/notebook.ipynb'

0


source


You can also use nbconvert - a WordPress plugin for Jupyter notebooks. Follow this detailed blog post ( https://www.andrewchallis.co.uk/portfolio/php-nbconvert-a-wordpress-plugin-for-jupyter-notebooks/ ) where the author explains the pros and cons.

0


source







All Articles