MarkView.Avalonia.Svg 12.0.3

dotnet add package MarkView.Avalonia.Svg --version 12.0.3
                    
NuGet\Install-Package MarkView.Avalonia.Svg -Version 12.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarkView.Avalonia.Svg" Version="12.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkView.Avalonia.Svg" Version="12.0.3" />
                    
Directory.Packages.props
<PackageReference Include="MarkView.Avalonia.Svg" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MarkView.Avalonia.Svg --version 12.0.3
                    
#r "nuget: MarkView.Avalonia.Svg, 12.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MarkView.Avalonia.Svg@12.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MarkView.Avalonia.Svg&version=12.0.3
                    
Install as a Cake Addin
#tool nuget:?package=MarkView.Avalonia.Svg&version=12.0.3
                    
Install as a Cake Tool

MarkView.Avalonia.Svg

NuGet Version NuGet Downloads Avalonia CI License

SVG image rendering extension for MarkView.Avalonia. Renders SVG files referenced in markdown images using Svg.Skia — the same backend that Avalonia itself uses for vector icons.

Installation

dotnet add package MarkView.Avalonia.Svg

Quick Start

Call UseSvg() before setting Markdown:

var viewer = new MarkdownViewer();
viewer.UseSvg();
viewer.Markdown = markdownText;

Or activate globally at application startup:

// App.axaml.cs
MarkdownViewerDefaults.Extensions.AddSvg();

Markdown syntax is unchanged — standard image syntax with an .svg URL:

![Logo](https://example.com/logo.svg)
![Badge](https://shields.io/badge/build-passing-green)
![Inline](data:image/svg+xml;base64,PHN2Zy8+)

Supported URL Formats

URL form Handled by
https://example.com/icon.svg HTTP download, SVG parse
relative/path/icon.svg (with BaseUri set) Resolved first; handled if the resolved URL is supported by SvgImageLoader
Any https:// / http:// URL Attempted speculatively; returns null if response is not valid SVG, letting the bitmap fallback load it
data:image/svg+xml;base64,… Base64 decode, SVG parse
data:image/svg+xml,… URL-decode, SVG parse
data:image/png;base64,… Not handled — passed to the next loader

The speculative HTTP/HTTPS rule means badge services like shields.io that return SVG without a .svg extension are handled transparently.

When using relative image paths, set MarkdownViewer.BaseUri to an HTTP/HTTPS base URL if you want this extension to fetch and parse those images as SVG.

How It Works

UseSvg() registers a SvgExtension which inserts SvgImageLoader at index 0 of renderer.ImageLoaders. Being first in the chain, it gets first pick on every image URL. If CanLoad returns false (e.g. a data:image/png URI), or if LoadAsync returns null (e.g. the HTTP response is not valid SVG), the next loader in the chain is tried.

Loading is asynchronous. The Image control is placed in the visual tree immediately; the SVG source is set once the download and parse complete. SvgImage is an AvaloniaObject and is created on the UI thread via Dispatcher.UIThread.

Writing a Custom Image Loader

Implement IImageLoader from the core package to handle any image source:

using MarkView.Avalonia.Extensions;

public class MyLoader : IImageLoader
{
    public bool CanLoad(string url) => url.StartsWith("myscheme://");

    public async Task<IImage?> LoadAsync(string url, CancellationToken ct = default)
    {
        // Return null to fall through to the next loader
        var bitmap = await FetchBitmapAsync(url, ct);
        return bitmap;
    }
}

// Insert at 0 to take priority, or Add() to run after built-in loaders
renderer.ImageLoaders.Insert(0, new MyLoader());

Or register via a IMarkViewExtension:

public class MyExtension : IMarkViewExtension
{
    public void Register(AvaloniaRenderer renderer)
        => renderer.ImageLoaders.Insert(0, new MyLoader());
}

viewer.Extensions.Add(new MyExtension());

License

MIT © Nicolas Musset

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
12.0.3 44 5/9/2026
12.0.2 114 4/21/2026
12.0.1 94 4/16/2026
12.0.1-beta.3 56 4/15/2026
12.0.1-beta.2 53 4/10/2026