In [1]:
from IPython.core.magic import register_line_magic
from IPython.core.display import display, HTML

@register_line_magic
def hello(line):
    '''line magic to display Hello + line as HTML <h1> element
    Usages:
        hello('world')
    
        %hello world
    '''
    display(HTML('<h1>Hello {}</h1>'.format(line)))
In [2]:
%whos
Variable              Type        Data/Info
-------------------------------------------
HTML                  type        <class 'IPython.core.display.HTML'>
display               function    <function display at 0x7f6433833950>
hello                 function    <function hello at 0x7f642c5187b8>
register_line_magic   function    <function _function_magic<...>c_deco at 0x7f6433308400>
In [3]:
help(hello)
Help on function hello in module __main__:

hello(line)
    line magic to display Hello + line as HTML <h1> element
    Usages:
        hello('world')
    
        %hello world

In [4]:
hello('world')

Hello world

In [5]:
%hello world

Hello world

In [6]:
hello('🌏🌍🌎')

Hello 🌏🌍🌎

In [7]:
%hello 🌏🌍🌎

Hello 🌏🌍🌎