Created
August 3, 2018 14:36
-
-
Save toby-p/6a81e68758652b7d439a96227be2289e to your computer and use it in GitHub Desktop.
Hide code in an HTML download of a Jupyter notebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I always forget this so saving it here; taken from: | |
| // http://chris-said.io/2016/02/13/how-to-make-polished-jupyter-presentations-with-optional-code-visibility/ | |
| // This script hides the code and leaves a button to toggle it on/off: | |
| <script> | |
| function code_toggle() { | |
| if (code_shown){ | |
| $('div.input').hide('500'); | |
| $('#toggleButton').val('Show Code') | |
| } else { | |
| $('div.input').show('500'); | |
| $('#toggleButton').val('Hide Code') | |
| } | |
| code_shown = !code_shown | |
| } | |
| $( document ).ready(function(){ | |
| code_shown=false; | |
| $('div.input').hide() | |
| }); | |
| </script> | |
| <form action="javascript:code_toggle()"><input type="submit" id="toggleButton" value="Show Code"></form> | |
| // This script hides the other elements like input prompts: | |
| <script> | |
| $(document).ready(function(){ | |
| $('div.prompt').hide(); | |
| $('div.back-to-top').hide(); | |
| $('nav#menubar').hide(); | |
| $('.breadcrumb').hide(); | |
| $('.hidden-print').hide(); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment