How to export Jupyter slides with hidden code

At the beginning of the notebook, create a new code cell with the following:

from IPython.display import HTML
HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
The raw code for this IPython notebook is by default hidden for easier reading.
To toggle on/off the raw code, click <a href="javascript:code_toggle()">here</a>.''')

Choose “Notes” as slide type and execute it. The output of this cell allows to toggle on/off the raw code.

Download the notebook as “Reveal.js slides” while the raw code is hidden and it will not appear in the slides.

Back