FluentAvalonia.MarkdownRender 12.1.3.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentAvalonia.MarkdownRender --version 12.1.3.1
                    
NuGet\Install-Package FluentAvalonia.MarkdownRender -Version 12.1.3.1
                    
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="FluentAvalonia.MarkdownRender" Version="12.1.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentAvalonia.MarkdownRender" Version="12.1.3.1" />
                    
Directory.Packages.props
<PackageReference Include="FluentAvalonia.MarkdownRender" />
                    
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 FluentAvalonia.MarkdownRender --version 12.1.3.1
                    
#r "nuget: FluentAvalonia.MarkdownRender, 12.1.3.1"
                    
#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 FluentAvalonia.MarkdownRender@12.1.3.1
                    
#: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=FluentAvalonia.MarkdownRender&version=12.1.3.1
                    
Install as a Cake Addin
#tool nuget:?package=FluentAvalonia.MarkdownRender&version=12.1.3.1
                    
Install as a Cake Tool

FluentAvalonia.MarkdownRender

面向 Avalonia / FluentAvalonia 的 Markdown 渲染控件,开箱即用,自动跟随 Fluent 主题与明暗色切换。

本组件由 AIDotNet/Markdown.AIRender(MIT)重命名并二次开发而来,新增了 GFM 表格渲染等能力。

特性

  • 标准 Markdown:标题、段落、列表、引用、分割线、粗斜体、行内代码、链接
  • 代码块:基于 AvaloniaEdit + TextMate 的语法高亮,覆盖 C/C++、C#、Java、Python、Go、Rust、TypeScript、JSON、YAML、Dockerfile、PowerShell 等数十种语言,附带一键复制
  • GFM 表格渲染
  • GitHub 风格警告框(Alert):> [!NOTE] / [!TIP] / [!IMPORTANT] / [!WARNING] / [!CAUTION]
  • 图片渲染(含 SVG、动图)
  • 内联 HTML 块渲染
  • 5 套内置配色主题:Default、OrangeHeart、Inkiness、ColorfulPurple、TechnologyBlue
  • 内置轻量多语言(zh-CN / zh-Hant / en-US),随 CurrentUICulture 自动切换

版本与依赖对照

版本号采用四段式:前三位对齐所适配的 Avalonia 版本,末位是组件自身修订号。

包版本 适配 Avalonia 目标框架 FluentAvaloniaUI
12.1.3.x 12.1.3 net10.0 3.1.0

主要依赖:Avalonia 12.1.3、Avalonia.AvaloniaEdit 12.0.0、AvaloniaEdit.TextMate 12.0.0、Svg.Controls.Skia.Avalonia 12.0.0.17、FluentAvaloniaUI 3.1.0、Markdig 1.4.0、SkiaSharp 4.151.2、TextMateSharp 2.0.4。

安装

从 nuget.org

dotnet add package FluentAvalonia.MarkdownRender

从 GitHub Packages

GitHub Packages 需要身份验证,先在仓库根目录添加 nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="github" value="https://nuget.pkg.github.com/RYCBStudio/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <github>
      <add key="Username" value="YOUR_GITHUB_USERNAME" />
      <add key="ClearTextPassword" value="YOUR_GITHUB_PAT" />
    </github>
  </packageSourceCredentials>
</configuration>

PAT 需要具备 read:packages 权限。然后:

dotnet add package FluentAvalonia.MarkdownRender

快速开始

1. 在 App.axaml 中引入样式(必须,否则控件无视觉外观):

<Application.Styles>
    <FluentTheme />
    <StyleInclude Source="avares://FluentAvalonia.MarkdownRender/Index.axaml" />
</Application.Styles>

2. 在页面中使用控件:

<UserControl xmlns:mdRender="https://github.com/RYCBStudio/FluentAvalonia.MarkdownRender">

    
    <mdRender:MarkdownRender Value="{Binding MarkdownText}" />

    
    <mdRender:MarkdownRender>
        <mdRender:MarkdownRender.Value>
            # 标题
            | 列 A | 列 B |
            | --- | --- |
            | 1 | 2 |
        </mdRender:MarkdownRender.Value>
    </mdRender:MarkdownRender>

</UserControl>

Value 为 string 类型的 Markdown 源文本。

主题

默认加载 Default 主题。若需切换,可在引入 Index.axaml 之后覆盖 Themes/Styles/_index.axaml 中的 StyleInclude,或直接在应用中引用所需的主题文件:

avares://FluentAvalonia.MarkdownRender/Themes/Styles/Default.axaml
avares://FluentAvalonia.MarkdownRender/Themes/Styles/OrangeHeart.axaml
avares://FluentAvalonia.MarkdownRender/Themes/Styles/Inkiness.axaml
avares://FluentAvalonia.MarkdownRender/Themes/Styles/ColorfulPurple.axaml
avares://FluentAvalonia.MarkdownRender/Themes/Styles/TechnologyBlue.axaml

明暗色由 Themes/MarkdownThemes/Light.axaml 与 Dark.axaml 提供,跟随应用主题变体自动切换。

本地化

控件内置字符串(警告框标题、复制提示等)位于 i18n/MdStrings.cs,依据 CultureInfo.CurrentUICulture 在 zh-CN / zh-Hant / en-US 之间自动选择,无需额外配置。如需覆盖,直接修改该文件或在你的应用中另建同名资源即可。

开发

dotnet build -c Release
dotnet pack -c Release -o ./artifacts

发布由 GitHub Actions 驱动:推送 v* 标签后自动打包,并推送到 GitHub Packages 与 nuget.org。nuget.org 走受信发布(Trusted Publishing / OIDC),由 NuGet/login 用 OIDC 换取短期 API key,无需在仓库里配置任何 Secret。

许可与致谢

依据 MIT 许可证要求,原始版权声明与许可声明予以保留。

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.1.3.9 0 11/28/2026
12.1.3.8 103 11/7/2026
12.1.3.7 96 11/7/2026
12.1.3.6 101 11/6/2026
12.1.3.5 95 11/6/2026
12.1.3.4 113 10/31/2026
12.1.3.3 115 10/24/2026
12.1.3.2 110 10/10/2026
12.1.3.1 129 10/2/2026

重命名自 Markdown.AIRender(https://github.com/AIDotNet/Markdown.AIRender),并新增 GFM 表格渲染支持。详见仓库 README 与 Release Notes。