Skip to content

Instantly share code, notes, and snippets.

@pierdom
Last active September 7, 2017 07:47
Show Gist options
  • Select an option

  • Save pierdom/ef54157499f713e62fee91c69432e914 to your computer and use it in GitHub Desktop.

Select an option

Save pierdom/ef54157499f713e62fee91c69432e914 to your computer and use it in GitHub Desktop.
[Code toggle in Jupyter] Add the following code in a cell in Jupyter notebook (with Python kernel). It allows to toggle the code cells, only leaving markdown and figures visible. Very convenient when exporting a notebook to HTML. #jupyter #python
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>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment