Skip to content

Instantly share code, notes, and snippets.

@kd2718
Created January 9, 2020 06:43
Show Gist options
  • Save kd2718/355419ebfcd642cb8e51b62644e8c87d to your computer and use it in GitHub Desktop.
Save kd2718/355419ebfcd642cb8e51b62644e8c87d to your computer and use it in GitHub Desktop.
toggle.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true,
"hide_input": false
},
"cell_type": "code",
"source": "from IPython.display import HTML\n\nHTML('''\n<script>\ncode_show=true; \nfunction code_toggle() {\n if (code_show){\n $('div.input').hide();\n } else {\n $('div.input').show();\n }\n code_show = !code_show\n} \n$( document ).ready(code_toggle);\n</script>\nThe raw code for this IPython notebook is by default hidden for easier reading.\n<a onclick=\"code_toggle()\"\">toggle code</a>\n''')",
"execution_count": 3,
"outputs": [
{
"data": {
"text/html": "\n<script>\ncode_show=true; \nfunction code_toggle() {\n if (code_show){\n $('div.input').hide();\n } else {\n $('div.input').show();\n }\n code_show = !code_show\n} \n$( document ).ready(code_toggle);\n</script>\nThe raw code for this IPython notebook is by default hidden for easier reading.\n<a onclick=\"code_toggle()\"\">toggle code</a>\n",
"text/plain": "<IPython.core.display.HTML object>"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
]
}
],
"metadata": {
"_draft": {
"nbviewer_url": "https://gist.github.com/f9035d7e063b77f20a07da363d2c75c8"
},
"celltoolbar": "Raw Cell Format",
"gist": {
"id": "f9035d7e063b77f20a07da363d2c75c8",
"data": {
"description": "toggle.ipynb",
"public": true
}
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.7.6",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"hide_input": true
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment