Blazor

Polhem.Markdown: A Markdown Viewer and Editor for Avalonia and Blazor

DEV Community: #blazor Jeff Tsai
Blazor

Polhem.Markdown 0.3.1 is an MIT-licensed Markdown viewer and editor for Avalonia and Blazor that parses once with Markdig and draws a shared document model, adding built-in Mermaid, math and highlighting plus a default link, image and HTML policy.

Key points

  • Core package parses with Markdig into its own document model, keeping Markdig types out of the public API.
  • Mermaid flowcharts, sequence diagrams, math and syntax highlighting ship in the main package; Blazor loads no third-party scripts.
  • Default policy drops raw HTML except a small allowlist and permits only http, https, mailto links and https images.
  • MarkdownOptions sets BaseUri and allowlists such as AllowedImageSchemes; Avalonia renders SVG only from trusted badge hosts.
  • Editor highlights per the viewer's parse, keeps source positions, syncs scrolling and jumps to source on Ctrl-click.
  • Streaming means resetting the Markdown property; only changed blocks rebuild. Targets net10.0 and Avalonia 12, and stays 0.x.

Why it matters

Markdown rendering looks trivial until the text comes from a model you do not control. Doing allowlisting once in a shared core instead of twice in each front end is the idea worth borrowing even if you keep your current viewer: a link scheme missed on one side is a hole you will not notice. The built-in Mermaid, math and highlighting also remove the CDN script that Blazor viewers usually pull in.

Two things to check before adopting. The packages are at 0.3.1 and the author warns the API can move in a minor release, and both net10.0 and Avalonia 12 push you onto the newest stack. The Avalonia editor has no search panel yet, so weigh that against your requirements.

Real-world use

  • A product with Avalonia desktop and mobile apps plus a Blazor web front end that must render the same AI replies identically.
  • Showing README-style documentation that relies on details, sup and kbd HTML instead of plain paragraphs.
  • An internal tool where developers edit Markdown in one pane and read the live preview in the other.
  • Blazor apps themed with MudBlazor or Fluent UI that need the component to follow the existing palette.

This summary was generated by the agent from the original post on DEV Community: #blazor. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message