How can I convert the notebook without some input cells?

1,798 views
Skip to first unread message

王怀庆

unread,
Sep 1, 2015, 11:56:44 AM9/1/15
to Project Jupyter
Hi all,

I've been looking for the method to convert the notebooks to other formats without some input cells all day, it is quite a great tool for literate programming. 
But I found that when I need to convert the notebook to html format, it will print the whole notebook as it looks like. But sometimes I just need to show the result not containing the source code. 
I've tried the method to modify custom.js and custom.css, but they only take effect when I edit the notebook. Is there any method to customize the converted file? 
Thank you!

Matthias Bussonnier

unread,
Sep 1, 2015, 12:35:38 PM9/1/15
to jup...@googlegroups.com
Hi, 

What you want to look at is custom html templates. 
you will find more information there:


you need to extend either full_html, or basic_html depending on your use case. 

If you want to remove all inputs, then just override input_group with an empty block. 

If you want to remove specific cell you need to dive into metadata and have an if/else
block with super() call depending  on wether you want to have the input or not. 

If a specific thing is not clear on the docs, tell us, we can extend and be more precise. 
-- 
M

Fernando Perez

unread,
Sep 1, 2015, 4:23:39 PM9/1/15
to jup...@googlegroups.com
Actually, Thomas recently wrote some examples specifically illustrating how to do this for HTML and PDF output, they are here:


They were used for a course we taught in Southampton this summer, it was all done against a deadline so we haven't had time to nicely fold them back into the official docs (or maybe it's been done and I just don't know about it :)

But in the meantime, you can grab them from there and see how they work, he even provided the necessary Javascript to expose buttons to reveal the code back on demand.

Cheers,

f


--
Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail

Ian Hawke

unread,
Sep 2, 2015, 3:44:23 AM9/2/15
to jup...@googlegroups.com
As a "live" example of that cell-hiding after nbconvert, I swiped that cell-hiding code from the Southampton tutorial for use in this tutorial:

At present it's only used to hide the "%matplotlib inline" cells from the final pdf (compare eg the start of
against page 55 of the pdf at

Ian

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/CAHAreOrjJqGCv4Ga2onVVQ6GjgQqDWi74hoqyN4YOtz2LGO5FA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages