Last active
July 10, 2023 15:41
-
-
Save Zsailer/5d1f4e357c78409dd9a5a4e5c61be552 to your computer and use it in GitHub Desktop.
Hide a single cell in Jupyter notebook
This file contains 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
from IPython.display import HTML | |
from IPython.display import display | |
# Taken from https://stackoverflow.com/questions/31517194/how-to-hide-one-specific-cell-input-or-output-in-ipython-notebook | |
tag = HTML('''<script> | |
code_show=true; | |
function code_toggle() { | |
if (code_show){ | |
$('div.cell.code_cell.rendered.selected div.input').hide(); | |
} else { | |
$('div.cell.code_cell.rendered.selected div.input').show(); | |
} | |
code_show = !code_show | |
} | |
$( document ).ready(code_toggle); | |
</script> | |
To show/hide this cell's raw code input, click <a href="javascript:code_toggle()">here</a>.''') | |
display(tag) | |
############### Write code below ################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to do this using R in a Markdown document in Vertex-Jupyter Lab to produce a HTML file? I can only seem to hide all code, rather than a specific cell.