Skip to content

Instantly share code, notes, and snippets.

@pkienzle
Last active October 4, 2022 21:52
Show Gist options
  • Save pkienzle/2b16bf3937f6006fd4ece7ac54880ea6 to your computer and use it in GitHub Desktop.
Save pkienzle/2b16bf3937f6006fd4ece7ac54880ea6 to your computer and use it in GitHub Desktop.
Markdown title in code cell
## Add this text to the top of your notebook to define '%title' magic.
## Use it to put an H3 title in the cell output, with the title shown
## in the JupyterLab Table-of-Contents sidebar:
## %title Cell title $some_local_variable
from IPython.core.magic import register_line_magic
@register_line_magic
def title(msg):
"""Add a markdown title (level 3) to the current cell output stream."""
from IPython.display import display, Markdown
display(Markdown("### "+msg))
del register_line_magic, title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment