Last active
October 4, 2022 21:52
-
-
Save pkienzle/2b16bf3937f6006fd4ece7ac54880ea6 to your computer and use it in GitHub Desktop.
Markdown title in code cell
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
## 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