Skip to main content

Include Html in Jupyter notebook



I just discovered something that is great and simple at the same time... how to include html in the Jupyter notebook.
As I want to create easily graphic content for different purposes (and you see in the last post what I mean) I find it just... sensational... or is it just me?

So, I will make a short example, as I am used to do... and lately we sill make something more complicated, maybe.

Ok... go in the cmd and write

jupyter notebook

or 

ipython notebook

create a notebook and write this in a cell



%%%html

<button onclick="alert('Ciao')">Ciao</button>


There we go! We have a button... it's all in html! And the button works. Isn't it great?

See ya.

Some languages you can use in the Jupyter Notebook.
%%html
Render the cell as a block of HTML
%%javascript
Run the cell block of Javascript code
%%latex
Render the cell as a block of latex
%%perl
%%perl script magic
Run cells with perl in a subprocess.
This is a shortcut for %%script perl
%%pypy
%%pypy script magic
Run cells with pypy in a subprocess.
This is a shortcut for %%script pypy
%%python
%%python script magic
Run cells with python in a subprocess.
This is a shortcut for %%script python
%%python2
%%python2 script magic
Run cells with python2 in a subprocess.
This is a shortcut for %%script python2
%%python3
%%python3 script magic
Run cells with python3 in a subprocess.
This is a shortcut for %%script python3
%%ruby
%%ruby script magic
Run cells with ruby in a subprocess.
This is a shortcut for %%script ruby

Comments