MarkView.Avalonia
12.0.3
dotnet add package MarkView.Avalonia --version 12.0.3
NuGet\Install-Package MarkView.Avalonia -Version 12.0.3
<PackageReference Include="MarkView.Avalonia" Version="12.0.3" />
<PackageVersion Include="MarkView.Avalonia" Version="12.0.3" />
<PackageReference Include="MarkView.Avalonia" />
paket add MarkView.Avalonia --version 12.0.3
#r "nuget: MarkView.Avalonia, 12.0.3"
#:package MarkView.Avalonia@12.0.3
#addin nuget:?package=MarkView.Avalonia&version=12.0.3
#tool nuget:?package=MarkView.Avalonia&version=12.0.3
MarkView.Avalonia
A Markdig-powered markdown viewer control for Avalonia UI v12. Drop MarkdownViewer into any Avalonia window or panel to render rich markdown — headings, code blocks, tables, task lists, links, images, and more — using native Avalonia controls with a fully customizable theme.
Installation
dotnet add package MarkView.Avalonia
Quick Start
Include the default theme and add MarkdownViewer to your XAML:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mv="using:MarkView.Avalonia">
<Window.Styles>
<StyleInclude Source="avares://MarkView.Avalonia/Themes/MarkdownTheme.axaml" />
</Window.Styles>
<mv:MarkdownViewer Markdown="# Hello, MarkView!" />
</Window>
Setting a base URI for relative links and images
viewer.BaseUri = new Uri("https://raw.githubusercontent.com/Kryptos-FR/MarkView.Avalonia/main/");
viewer.Markdown = markdownText; // relative image paths resolved against BaseUri
Handling link clicks
viewer.LinkClicked += (_, e) =>
{
// e.Url contains the clicked URL
Process.Start(new ProcessStartInfo(e.Url) { UseShellExecute = true });
};
LinkClickedEvent is an Avalonia routed event (bubbles up) — subscribe globally once at app startup to handle all viewers:
// App.axaml.cs — applies to every MarkdownViewer in the application
MarkdownViewer.LinkClickedEvent.AddClassHandler<MarkdownViewer>((_, e) =>
Process.Start(new ProcessStartInfo(e.Url) { UseShellExecute = true }));
Navigating to an anchor
viewer.ScrollToAnchor("my-heading"); // scrolls to the heading's anchor position
Using a custom Markdig pipeline
viewer.Pipeline = new MarkdownPipelineBuilder()
.UseSupportedExtensions()
.UseAlertBlocks()
.UseFootnotes()
.Build();
Extension Methods
Convenience methods configure a pipeline with a single opt-in feature:
viewer.UseFootnotes();
viewer.UseAlertBlocks();
viewer.UseAbbreviations();
viewer.UseFigures();
viewer.UseMediaLinks();
To combine several opt-in features, build the pipeline explicitly (see above).
Application-Wide Defaults
MarkdownViewerDefaults lets you set a pipeline and/or extensions once so that every MarkdownViewer in the application inherits them automatically — no need to configure each instance:
// App.axaml.cs
MarkdownViewerDefaults.Pipeline = new MarkdownPipelineBuilder()
.UseSupportedExtensions()
.UseFootnotes()
.UseAlertBlocks()
.Build();
MarkdownViewerDefaults.Extensions.AddTextMateHighlighting();
MarkdownViewerDefaults.Extensions.AddSvg();
MarkdownViewerDefaults.Extensions.AddMermaid();
Per-instance Pipeline and Extensions take precedence over the defaults; an extension object shared between the defaults list and an instance list is only registered once per render.
Supported Markdown Features
CommonMark baseline (always on)
| Feature | Notes |
|---|---|
| Headings H1–H6 | CommonMark |
| Bold, italic | CommonMark |
| Inline code | CommonMark |
| Fenced code blocks | CommonMark |
| Blockquotes | CommonMark |
| Ordered and unordered lists | CommonMark, tight and loose |
| Links and autolinks | CommonMark + extension |
| Images | CommonMark, remote URLs loaded async |
| Thematic breaks | CommonMark |
| Hard line breaks | CommonMark (\ or two spaces) |
HTML <br> / <br /> |
Rendered as line break |
Extensions (enabled by UseSupportedExtensions())
| Feature | Syntax |
|---|---|
| Strikethrough | ~~text~~ |
| Subscript | ~text~ |
| Superscript | ^text^ |
| Underline (inserted) | ++text++ |
| Highlight (marked) | ==text== |
| Task lists | - [x] item |
| Pipe tables | GFM-style \| col \| col \| |
| Grid tables | RST-style grid tables |
| Autolinks | bare https://… URLs |
Opt-in extensions
These require adding .UseXxx() to the pipeline (see Extension Methods below):
| Feature | Activation | Syntax |
|---|---|---|
| Footnotes | UseFootnotes() |
[^1] / [^1]: … |
| GitHub alert blocks | UseAlertBlocks() |
> [!NOTE] etc. |
| Abbreviations | UseAbbreviations() |
*[HTML]: … |
| Figures | UseFigures() |
^^^ / ^^^ caption |
| YouTube embeds | UseMediaLinks() |
 |
Extension Packages
MarkView.Avalonia ships optional NuGet packages that add richer rendering capabilities. Each package implements IMarkViewExtension and is activated via a convenience method on MarkdownViewer, or globally via MarkdownViewerDefaults.Extensions.AddXxx().
Syntax Highlighting (MarkView.Avalonia.SyntaxHighlighting)
Adds TextMate grammar-based syntax highlighting to fenced code blocks.
dotnet add package MarkView.Avalonia.SyntaxHighlighting
viewer.UseTextMateHighlighting(); // DarkPlus / LightPlus by default
// or with custom themes:
viewer.UseTextMateHighlighting(darkTheme: ThemeName.Monokai, lightTheme: ThemeName.QuietLight);
The extension replaces the built-in CodeBlockRenderer with TextMateCodeBlockRenderer, which tokenises each line and emits coloured Run elements. Unsupported languages fall back to the default monochrome rendering automatically.
Colours update in-place when the user switches between light and dark themes — no document rebuild or scroll reset.
Available ThemeName values are defined by TextMateSharp.Grammars: DarkPlus, LightPlus, Monokai, SolarizedDark, SolarizedLight, and more.
SVG Images (MarkView.Avalonia.Svg)
Renders SVG images embedded in markdown (), including data:image/svg+xml data URIs and badge-service URLs that return SVG without a .svg extension.
dotnet add package MarkView.Avalonia.Svg
viewer.UseSvg();
The extension inserts SvgImageLoader at the front of the image loader chain. Regular raster images continue to load via the built-in HTTP fallback.
Mermaid Diagrams (MarkView.Avalonia.Mermaid)
Renders fenced mermaid code blocks as SVG diagrams using the Mermaider library (pure .NET, no browser required). Works on all platforms including Linux. Diagrams re-render automatically when the user switches between light and dark themes.
dotnet add package MarkView.Avalonia.Mermaid
viewer.UseMermaid();
Markdown syntax:
```mermaid
graph TD
A[Start] --> B{Decision}
B -- Yes --> C[End]
B -- No --> A
```
Combining extensions
All three can be stacked:
viewer
.UseTextMateHighlighting()
.UseSvg()
.UseMermaid();
Extensions are applied in the order they are added to viewer.Extensions. Each extension's Register method is called once per render pass, before the Markdig pipeline is set up.
Writing your own extension
Implement IMarkViewExtension from the core package:
using MarkView.Avalonia.Extensions;
using MarkView.Avalonia.Rendering;
public class MyExtension : IMarkViewExtension
{
public void Register(AvaloniaRenderer renderer)
{
// swap a renderer, add an image loader, or set a code highlighter
renderer.ObjectRenderers.ReplaceOrAdd<CodeBlockRenderer>(new MyCodeBlockRenderer());
}
}
viewer.Extensions.Add(new MyExtension());
Theming / Customization
Include MarkdownTheme.axaml for default styles. Override any style class in your own Styles to customise appearance:
| Style class | Applied to | Controls |
|---|---|---|
markdown-h1 … markdown-h6 |
Headings | TextBlock |
markdown-paragraph |
Paragraphs | TextBlock |
markdown-code-block |
Code blocks | Border |
markdown-code-inline |
Inline code | Border |
markdown-blockquote |
Blockquotes | Border |
markdown-list |
Lists | StackPanel |
markdown-thematic-break |
Horizontal rules | Separator |
markdown-image |
Images | Image |
markdown-link |
Hyperlinks | HyperlinkButton |
markdown-table |
Tables | Grid |
markdown-table-cell |
Table cells | Border |
markdown-table-header |
Header cells | Border |
markdown-marked |
Highlighted text (==…==) |
Span |
markdown-alert |
Alert block container | Border |
markdown-alert-note … markdown-alert-caution |
Per-kind border colour | Border |
markdown-alert-header |
Alert kind label | TextBlock |
markdown-figure |
Figure container | Border |
markdown-figure-caption |
Figure caption | TextBlock |
markdown-abbr |
Abbreviation with tooltip | TextBlock |
markdown-footnote-ref |
Footnote reference link | HyperlinkButton |
markdown-footnote-group |
Footnote definition list | StackPanel |
markdown-footnote-item |
Individual footnote row | Grid |
Example — increase heading size and add a bottom border:
<Style Selector="TextBlock.markdown-h1">
<Setter Property="FontSize" Value="36" />
<Setter Property="Foreground" Value="#1A1A2E" />
<Setter Property="Margin" Value="0,12,0,6" />
</Style>
Text Selection
MarkdownViewer supports full document-wide text selection:
- Click + drag to select a range.
Ctrl+Ato select all text.Ctrl+Cto copy the selection to the clipboard.
Programmatic API:
viewer.SelectAll();
viewer.ClearSelection();
string text = viewer.GetSelectedText();
await viewer.CopyToClipboardAsync();
Images and task-list checkboxes are skipped during selection (same behaviour as all reference libraries).
Known Limitations
| Limitation | Detail |
|---|---|
| Images are non-selectable | Images in inline position are embedded as InlineUIContainer — selection skips around them. This is the same behaviour as all reference libraries. |
| Task checkboxes are non-selectable | Same reason as images. |
| Anchor scroll is instant | BringIntoView() jumps without animation. Smooth scrolling is a future improvement. |
License
MIT © Nicolas Musset
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages (3)
Showing the top 3 NuGet packages that depend on MarkView.Avalonia:
| Package | Downloads |
|---|---|
|
MarkView.Avalonia.SyntaxHighlighting
TextMate syntax highlighting extension for MarkView.Avalonia. |
|
|
MarkView.Avalonia.Mermaid
Mermaid diagram rendering extension for MarkView.Avalonia. |
|
|
MarkView.Avalonia.Svg
SVG image rendering extension for MarkView.Avalonia. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.0.3 | 26 | 5/9/2026 |
| 12.0.2 | 144 | 4/21/2026 |
| 12.0.1 | 151 | 4/16/2026 |
| 12.0.1-beta.3 | 66 | 4/15/2026 |
| 12.0.1-beta.2 | 60 | 4/10/2026 |
| 12.0.1-beta.1 | 48 | 4/8/2026 |