MarkView.Avalonia.Math
12.2.1
dotnet add package MarkView.Avalonia.Math --version 12.2.1
NuGet\Install-Package MarkView.Avalonia.Math -Version 12.2.1
<PackageReference Include="MarkView.Avalonia.Math" Version="12.2.1" />
<PackageVersion Include="MarkView.Avalonia.Math" Version="12.2.1" />
<PackageReference Include="MarkView.Avalonia.Math" />
paket add MarkView.Avalonia.Math --version 12.2.1
#r "nuget: MarkView.Avalonia.Math, 12.2.1"
#:package MarkView.Avalonia.Math@12.2.1
#addin nuget:?package=MarkView.Avalonia.Math&version=12.2.1
#tool nuget:?package=MarkView.Avalonia.Math&version=12.2.1
MarkView.Avalonia.Math
LaTeX math rendering extension for MarkView.Avalonia. Renders $...$ (inline) and $$...$$ (block) math using CSharpMath's SkiaSharp renderer — pure .NET, no browser, no WebView, no JavaScript runtime.
Because $ is common in ordinary prose (currency amounts, etc.), this parsing is opt-in only — enabling it changes how literal $ characters are interpreted in your documents.
Installation
dotnet add package MarkView.Avalonia.Math
Quick Start
Call UseMath() before setting Markdown:
var viewer = new MarkdownViewer();
viewer.UseMath();
viewer.Markdown = markdownText;
Or activate globally at application startup:
// App.axaml.cs
MarkdownViewerDefaults.Extensions.AddMath();
MarkdownViewerDefaults.Pipeline = new MarkdownPipelineBuilder()
.UseSupportedExtensions()
.UseMathematics()
.Build();
Unlike most opt-in extensions in this repo, math needs both a pipeline change (.UseMathematics(),
so $/$$ are even parsed) and a renderer registration — UseMath() does both for you.
Inline: Einstein's famous equation is $E = mc^2$.
Block:
$$
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
$$
Theme Awareness
Formulas are rendered with colours matching the active Avalonia theme variant (dark #FAFAFA,
light #27272A text), and are automatically re-rendered when the user switches between light and
dark.
Combining with Mermaid
MathExtension and MermaidExtension can both be registered in either order — each scans for
(rather than assumes) its position in the renderer list, so $$...$$ blocks are never mistaken
for a Mermaid diagram or a plain code block regardless of registration order.
Error Handling
Invalid LaTeX renders CSharpMath's own inline error text rather than throwing. Unexpected rendering failures fall back to a plain-text panel (block math) or leave the last successfully rendered formula in place (inline math).
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. |
-
net10.0
- CSharpMath.SkiaSharp (>= 0.5.1)
- MarkView.Avalonia (>= 12.2.1)
- SkiaSharp (>= 4.148.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.