Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

How to export an IPython notebook to HTML for a blog post?

What is the best way to get an ipython notebook into html format for use in a blog post?

It is easy to turn an ipython notebook into a PDF, but I'd rather publish as an html notebook.

I've found that if I download the notebook as a .ipynb file, then load it onto gist, then look at it with the ipython notebook viewer (nbviewer.ipython.org), THEN grab the html source, I can paste it into a blog post (or just load it as html anywhere) and it looks about right. However, if I use the "print view" option directly from ipython, the source contains a bunch of javascript rather than the processed html, which is not useful since the images and text are not directly included.

The %pastebin magic is also not particularly helpful for this task, since it pastes the python code and not the ipython notebook formatted code.

EDIT: Note that this is under development; see the comments under the accepted answer.

EDIT May 2 2014: As per Nathaniel's comment, a new answer is needed for ipython 2.0

question from:https://stackoverflow.com/questions/12502187/how-to-export-an-ipython-notebook-to-html-for-a-blog-post

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The right way is described in: http://blog.fperez.org/2012/09/blogging-with-ipython-notebook.html. Then you can do nbconvert -f blogger-html your_notebook.ipynb to get the html code for your post.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...