1

I have a static blog made with hakyll, and some ipython notebooks -I'd like to share.

My solution

ipython nbconvert --to markdown notebook.ipynb

Gives me:

notebook.md
/notebook_files/

notebook_files contains:

notebook_1.png
notebook_2.png
notebook_3.png

I move the .png files into my /images folder.

I copy the notebook.md to the /posts folder.

In notebook.md I search:

![png](notebook_files/notebook_1.png)

and replace it by:

![png](/images/notebook_1.png)

Also, I need to add python prefixes to the code so that it detects python syntax:

```phyton
code
```

So, doable, but painful if I have to repeat it for evert post.

Question:

Is there some way, either standard or smarter, to do this?

alberto
  • 2,625
  • 4
  • 29
  • 48

1 Answers1

1

I think you will have to dig a bit in the code (maybe slighly in python). Nbviewer is a library, so you can import it and do what the command line does, but manually to not create subfolder. Than you want to inject than into hakyll to create new pages. You then just want to inject nbviewer css into your hakyll.

Worse case you use nbconvert to create the files in a temp directory, and read them again from haskell.

Matt
  • 27,170
  • 6
  • 80
  • 74