Runtime API Demo

# Load the %%nbprint cell magic so later cells can use it.
%load_ext nbprint.config.magic
from IPython.display import Markdown, display
from nbprint import NBPrintCell, Style, Font

# Route this cell to covermatter and centre it.
NBPrintCell(section="covermatter",
            css=":scope, :scope * { text-align: center; }\n:scope h1 { font-size: 32pt; }")
display(Markdown("# Big Centered Headline"))

Big Centered Headline

# Context-manager form wraps the display output in a styled div.
with NBPrintCell(style=Style(font=Font(size=18))):
    display(Markdown("This text inherits the NBPrintCell `Style`."))

This text inherits the NBPrintCell Style.

%%nbprint section=frontmatter css=":scope { font-style: italic; }"
from IPython.display import Markdown, display
display(Markdown("Magic-line metadata: routed to frontmatter."))

Magic-line metadata: routed to frontmatter.

Body Content

Cells with no NBPrintCell() call or %%nbprint magic fall through to middlematter by default.