Skip to main content

Module markdown

Module markdown 

Source
Expand description

MarkdownView — render a Markdown string as formatted text with images.

Uses pulldown-cmark for parsing, then converts the event stream into a flat list of styled lines, inline image runs, and image placeholders. Word-wrapping is computed in layout() using the standalone measure_text_metrics function so no DrawCtx is needed at layout time.

§Image support

Pass an image_provider closure via MarkdownView::with_image_provider. It receives the image URL/path string and should return Some((rgba_bytes, width, height)) or None for unknown images. The data must be tightly-packed RGBA8 in row-major order, top-row first.

Images are decoded and cached on the first layout() call and then drawn via DrawCtx::draw_image_rgba() on every paint().

§Supported Markdown features

  • Headings H1–H4 (larger font sizes)
  • Paragraphs (word-wrapped)
  • Bullet lists (-/*) with “• “ prefix
  • Ordered lists with “N. “ prefix
  • Inline code `x` (highlight)
  • Fenced code blocks (background box)
  • Horizontal rules (thin separator line)
  • Images via image_provider callback; compact inline placeholder when unavailable
  • Links (coloured text, URL is not opened — add on_link_click if needed)

Structs§

MarkdownView
A widget that renders a Markdown string as formatted, word-wrapped text with optional image support.