Skip to content

Instantly share code, notes, and snippets.

@okdewit
Created April 17, 2018 22:32
Show Gist options
  • Save okdewit/81ba0bb8cda62270839e52c4592fe1b2 to your computer and use it in GitHub Desktop.
Save okdewit/81ba0bb8cda62270839e52c4592fe1b2 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<script>\n",
" code_shown = true;\n",
" function code_toggle() {\n",
" for (let el of document.querySelectorAll('div.input')) el.style.display = code_shown ?'none':'flex';\n",
" code_shown = !code_shown\n",
" }\n",
"</script>\n",
"<form action=\"javascript:code_toggle()\"><input type=\"submit\" value=\"Toggle\"></form>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import HTML\n",
"\n",
"HTML('''<script>\n",
" code_shown = true;\n",
" function code_toggle() {\n",
" for (let el of document.querySelectorAll('div.input')) el.style.display = code_shown ?'none':'flex';\n",
" code_shown = !code_shown\n",
" }\n",
"</script>\n",
"<form action=\"javascript:code_toggle()\"><input type=\"submit\" value=\"Toggle\"></form>''')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment