[IPython-dev] Status of printing in the notebook

Brian Granger ellisonbg at gmail.com
Tue Jan 31 16:09:03 EST 2012


Mark,

Sorry it has taken a few days to get back to you about this.  There is
a lot of activity on the notebook right now and I am having a tough
time keeping up (even though I am working on it full time!).

First, I will fix the notebook printing hopefully today, maybe early tomorrow.

On Sat, Jan 28, 2012 at 6:22 PM, Mark Voorhies <mark.voorhies at ucsf.edu> wrote:
> I just started using the notebook yesterday (following an upgrade to Firefox 9)
> and it's awesome -- so much so that I'm switching to it for everyday work and
> am planning to teach from it in April.
>
> One thing I would like to hack on is an equivalent to the qtconsole's "export
> with inlined images" (xhtml+svg / html+inlined png) function (so that I can
> save/e-mail finished work as a single file with no dependencies).

Yes, we *really* would like to have this capability and are more than
willing to help you get started.  Here is a few points:

* The IPython.nbformat.v3 subpackage has an infrastructure for
notebook readers/writers.  We currently have one for .json and .py
files.  This is the place to create one for exporting to HTML.
* Exporting to raw HTML is not quite possible.  The reason for this is
that we use a couple of Javascript libraries:  MathJax for rendering
latex embedded in the HTML, CodeMirror for formatting the code areas
with syntax highlighting, and A Markdown parser that converts Markdown
to HTML.  We will have to figure out substitutes for these JS
libraries in the HTML export.
* There are two possible ways of generating raw HTML:

1) First export to reST and then use rst2html to get to the HTML.
Some benefits to this, but the downside is that raw Markdown/HTML
cells would get lost in the process (although I think that reST
suports raw HTML inclusion.  Also, this would make it more difficult
to control exactly what the HMTL looks like (IOW use our current CSS
styling).
2) Use a templating library to export directly to HTML.  I think this
is very worth pursuing as a first line of attack.  The would allow you
to simply recreate the right HTML structure with the proper id/classes
and then inline our CSS.  It would give you exactly the same look as
we have now.  We would still need to figure out how to handle MathJax,
CodeMirror and Markdown though.

I imagine that in the long run we will support both of these routes.
Once we have the writers in place in IPython.nbformat.v3, it will be a
simple matter of incorporating them into the notebook server.

Here is a github issue where we should continue this discussion:

https://github.com/ipython/ipython/issues/860

Fernando even has a draft reST exporter implemented.  Let us know if
you have questions.

Cheers,

Brian

> The print window circa a50ac36bd554 looks like the right starting point (it
> would just need inlining of the css and images), but it looks like this version
> was scrapped when the wijmo menus were added and that there now may be
> different ideas for printing (https://github.com/ipython/ipython/issues/1292).
>
> So -- is this a good time to start working on this sort of inlining (and, if so,
> which code should I be looking at) or would it be better to wait for the next
> print window revision (and is there an issue/PR that I should be watching
> for this)?
>
> Thanks,
>
> Mark
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com



More information about the IPython-dev mailing list