Skip to content

Markdown

The Markdown widget displays Markdown-formatted text in a Mercury App. It converts Markdown to HTML and renders it as a first-class widget with full Mercury layout support.

The Markdown rendering dependency is installed automatically with the mercury package, so no additional setup is required.

The widget supports Mercury layout placement via the position argument:

  • "inline" — render in the main notebook flow (default)
  • "sidebar" — render in the sidebar
  • "bottom" — render after all notebook cells

Render Markdown in the main view:

import mercury as mr
mr.Markdown(
"# Hello\nThis is **Markdown** rendered in Mercury."
)

Use position to control where the Markdown is displayed:

import mercury as mr
mr.Markdown(
"## Sidebar note\nYou can put documentation or hints here.",
position="sidebar"
)
import mercury as mr
mr.Markdown(
"_Footer-style text_ shown at the bottom.",
position="bottom"
)

The Markdown widget supports standard Markdown syntax.

# Heading 1
## Heading 2
### Heading 3

*italic*
**bold**
***bold and italic***

Unordered list:

- Item A
- Item B
- Item C

Ordered list:

1. First
2. Second
3. Third

[Mercury documentation](https://mljar.com/mercury)

Inline code:

Use `print()` to display output.


type: string

Markdown content to render.


type: "inline" | "sidebar" | "bottom"

Controls where the widget is rendered.

Default: "inline"


type: string

Unique identifier used to reuse the same widget instance.