“The first duty in life is to be as artificial as possible. What the second duty is no one has as yet discovered.” Oscar Wilde
 
Introduction and Hello!

Introduction and Hello!

So time to start a new blog! Devoted to python, R and artificial intelligence.

The first post, however, is somewhat mundane.

I like Jupyter notebooks, which can be used to write presentable python code. I want to turn Jupyter notebooks – more or less automatically – into a blog post on a WordPress content management system. Especially, we want syntax color highlighting and pretty pictures coming out of the analysis in Jupyter Notebook.

I found a few helpful references on the web, especially this one, however, my WordPress Installation behaved slightly differently, so I will describe what I did.

First of all you need these

Pre-requisites:

  • You need python installed. Personally, I prefer Anaconda. Jupyter, by the way, comes with it.
  • You need a WordPress Installation. This can be with either hosted, e.g. https://wordpress.com/, or a docker-based installation at digital ocean, the principal setup is described in this excellent post.

With these pre-requisites out of the way, let’s get started:

  1. Explanation: This first step is necessary to have syntax color highlighting.  Now, in your WordPress Administration Dashboard (or Panel) go to plugins and install Crayon Syntax Highlighter. You can than copy everything across manually (including pictures) or you can do the following:
  2. This is for convenience (it keeps the Jupyter notebook structure and deals nicely with the pictures).a) Export your Jupyter notebook to html like so: Go to the folder, where your Jupyter notebook has been saved. Run the following command (Linux, for Windows change as appropriate):jupyter nbconvert –to html –template basic <notebook.ipynb> <notebook.html>b) Now paste the contents of the file named <notebook.html> into WordPress, using the Text option (not the Visual Option)

    c)Now “clean” the html:
    Copy the content of the first code box. Click outside, then inside the box, then click onto <>, which after you’ve installed Crayon Syntax Highlighter should have appeared at the top of your Editing box (top right hand side). When the Crayon Syntac Highligher Box opens,  paste the Code inside the “Code-box”

You’re done!

See how this performs see the next post : Simple Sin Function

PHP Code Snippets Powered By : XYZScripts.com