Skip to content

Extras

MarkdownViewer

Bit.BlazorUI.ExtrasMdViewerMD

BitMarkdownViewer parses Markdown into an AST and renders it straight to the Blazor render tree - no JavaScript interop, no third-party packages. Composable pipelines add exactly the flavors a document needs, untrusted input is sanitized and bounded by default, and the parsed tree, the rendering of any node and the words the renderers write are all yours to change.

Rendering & interaction

Inline rendering, templates for code blocks, images and links, interactive task lists, localized strings, accessibility, and a live playground.

Inline

Inline renders the root as a span without the paragraph wrappers, so a short piece of Markdown can sit inside a sentence, a table cell or a label. Other blocks still render; a document holding one keeps a div laid out inline.

Formatting a value in place: the fastest path is Span<T> - read why (opens in a new tab)

Templates

CodeBlockTemplate, ImageTemplate and LinkTemplate draw those nodes with your own markup - a highlighter, a copy button, a lightbox, a router-aware link. They run after URL sanitizing and the ImageRendering policy, and their output is outside the viewer's stylesheet, so a component keeps its own look.

Every code block below is drawn by the template, not by the viewer:

csharp
var pipeline = new BitMarkdownPipelineBuilder().UseGitHubFlavored().Build();
bash
dotnet add package Bit.BlazorUI.Extras

And every link, like the bit platform (opens in a new tab), is a BitLink.

Interactive task lists

Handling OnTaskChanged enables the checkboxes: a tick reports the index, the new state and the source rewritten to match, so storing it is one assignment. Each box is named after its item's text, and a disabled viewer keeps them read-only.


Release checklist

  • Write the parser
  • Write the docs
  • Polish
    • Icons
    • Copy
Tick a box to see the rewritten source.

Localization

The few words the renderers write themselves - alert titles, footnote back-links, the names of a table's scroll region, a permalink or a task box, the new-tab notice of a link - default to English. UseStrings() replaces them per pipeline; the numbered ones take their number through {0}.

Warnung

Der Titel dieses Kastens kommt aus den Texten der Pipeline, nicht aus dem Dokument.

Auch die Tabelle, die Fußnote1 und der externe Link (öffnet in neuem Tab) tragen deutsche Namen.

SpalteWert
eins1

Fußnoten


  1. Ihr Rücklink wird als „Zurück zur Referenz 1“ angesagt. ↩︎

Accessibility

HeadingLevelOffset nests the document's outline under the page's own: here # renders as an h4 under the card's h3. AriaLabel names the document and makes it a region. HeadingIdPrefix keeps its heading ids, and the links to them, apart from every other comment's. Links are underlined and tell a screen reader when they open a new tab; code blocks and wide tables are keyboard-scrollable; in-page links keep working under <base href>.

Comment by Sam

Looks good to me

Tested on Firefox and Safari. One nit, under Naming:

Naming

MaxLength reads well, but the docs (opens in a new tab) should say it counts characters.

var viewer = new BitMarkdownViewer { MaxLength = 100_000 };

Playground

Everything above, live: type on the left and switch the flavor to see the same source under the three ready-made pipelines.

Flavor:
Advanced: the GitHub flavors plus front matter, the emphasis extras, :::containers, definition lists, abbreviations, figures, :sparkles: emoji and heading ids.

BitMarkdownViewer

A native Blazor Markdown viewer written in pure C# - no JavaScript, no innerHTML, and no external dependencies zero external dependencies.

Feature highlights

  • Bold, italic, bold italic, and strikethrough
  • H2O, x2, inserted and highlighted (the emphasis extras)
  • Links (opens in a new tab) and images
  • Nested lists:
    1. First item
    2. Second item
      • nested bullet
  • Task lists:
    • Parse blocks
    • Conquer the world

Code

public static BitMarkdownDocumentNode Parse(string? markdown)
{
    var document = new BitMarkdownDocumentNode();
    return document;
}

Tip

Switch the Flavor above to Basic and watch this become an ordinary block quote.

FeatureSupportedNotes
TablesYesWith column alignment
Raw HTMLNoEscaped for safety

Reference links keep the prose clean1: see the bit platform (opens in a new tab) site.

Emoji 🚀 🎉, bare URLs https://learn.microsoft.com (opens in a new tab) and © 2026.


Made with C# and the Blazor render tree.

Footnotes


  1. The destination is declared once, at the bottom. ↩︎

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.