CodeWF.Markdown
CodeWF.Markdown is an Avalonia 12-based Markdown rendering control, typography themes, and runnable samples. This repository is split from CodeWF.AvaloniaControls and focuses on maintaining MarkdownViewer, theme resources, and related tests.
Packages
| Package | Description |
|---|---|
CodeWF.Markdown |
Full MarkdownViewer, supports common Markdown elements, code highlighting, image preview, SVG/images, math rendering extensions, multilingual resources, incremental rendering, export image helpers, and rich HTML clipboard helpers. |
CodeWF.Markdown.Themes |
Default control templates and multiple typography themes. |
Host Application Helpers
MarkdownDocumentExporterandExportKindprovide one-stop PNG, selectable-text PDF, and Word.docxexport APIs from Markdown strings, Markdown files, orMarkdownExportDocument. PDF body text remains selectable and copyable, while shared image loading and rasterization embed relative local,data:image, HTTP(S), SVG/GIF/WebP images.MarkdownHtmlClipboardExtensions,CopyKind, andMarkdownSocialCopyProfilesprovide rich HTML copy for WeChat Official Account, Zhihu, and Juejin. Host applications pass the Markdown text, active typography theme, and target platform; the library renders inline HTML and writestext/html, macOSpublic.html, and native WindowsHTML Format.- New platforms can be added through
MarkdownSocialCopyProfile; custom typography can be supplied withMarkdownExportStyleor application-registered theme resources.
Installation
Install-Package CodeWF.Markdown
Install-Package CodeWF.Markdown.Themes
Usage
In App.axaml, import the theme package:
<Application
xmlns="https://github.com/avaloniaui"
xmlns:markdown="https://codewf.com">
<Application.Styles>
<FluentTheme />
<markdown:MarkdownThemes TypographyTheme="Simple" />
</Application.Styles>
</Application>
Use MarkdownViewer in a page:
<UserControl
xmlns="https://github.com/avaloniaui"
xmlns:md="https://codewf.com">
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<md:MarkdownViewer Markdown="{Binding Markdown}" />
</ScrollViewer>
</UserControl>
Repository Structure
src/CodeWF.Markdown MarkdownViewer class library
src/CodeWF.Markdown.Themes Control templates and typography themes
src/CodeWF.Markdown.Sample Sample project
tests/CodeWF.Markdown.Tests Rendering and diff service tests
Ideal For
- Avalonia applications that need to render Markdown content directly.
- Need unified typography themes for documentation, changelogs, AI responses, or help centers.
- Need support for images, SVG, code highlighting, multilingual resources, incremental rendering, embedded export images, and rich HTML paste into web editors.
- Want to use sample projects to verify the rendering of different Markdown content on the desktop.
Build
dotnet restore CodeWF.Markdown.slnx
dotnet build CodeWF.Markdown.slnx --no-restore