This post documents how to set up Jupyter notebooks with Ruby support and embed them in blog posts.

Pre-conditions

gem install iruby
iruby register --force
brew install jupyter

Later, you can check the installed versions of IRuby with:

for version in $(rbenv versions --bare); do echo "=== Ruby $version ===" && RBENV_VERSION=$version gem list iruby 2>/dev/null | grep -E "^iruby" || echo "iruby not installed"; done

Local usage:

jupyter lab

Webbrowser usage: http://localhost:8888/lab

Workflow

  1. Create your notebook (.ipynb file) - either via Jupyter Lab or by writing the JSON directly

  2. Convert to HTML:

/opt/homebrew/opt/jupyterlab/bin/jupyter nbconvert --to html notebooks/your-notebook.ipynb
  1. Extract the <main> content from the generated HTML

  2. Add the Jupyter CSS to your site’s stylesheet (see assets/css/codeblock.css)

  3. Embed the HTML directly in your blog post

Example