DotNetElements.Wpf.Markdown 0.4.0

Prefix Reserved
dotnet add package DotNetElements.Wpf.Markdown --version 0.4.0
                    
NuGet\Install-Package DotNetElements.Wpf.Markdown -Version 0.4.0
                    
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="DotNetElements.Wpf.Markdown" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetElements.Wpf.Markdown" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="DotNetElements.Wpf.Markdown" />
                    
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 DotNetElements.Wpf.Markdown --version 0.4.0
                    
#r "nuget: DotNetElements.Wpf.Markdown, 0.4.0"
                    
#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 DotNetElements.Wpf.Markdown@0.4.0
                    
#: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=DotNetElements.Wpf.Markdown&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=DotNetElements.Wpf.Markdown&version=0.4.0
                    
Install as a Cake Tool

About

This project provides a markdown renderer for WPF. Markdown is rendered to a FlowDocument. This implementation uses the popular Markdig library for parsing.

At the current state, all common markdown features are supported (There might be some missing edge cases). Some of the most used Markdig extensions are also supported.

Supported features:
  • CommonMark

Currently there are no plans to support Raw HTML and HTML blocks

  • Pipe tables
  • Alert blocks (github)
  • Task lists
  • Code block syntax highlighting
  • Emphasis extras
  • Defined image size (![Image](img/exampleImg.png=100x100))
  • Auto links
Missing features we would like to implement:
  • Footnotes
  • Emoji extension (add support for colored font emoji)
  • Option to implement other Markdig extensions and provide custom renderers
  • Improved theme for light mode
  • Default theme for dark mode
  1. Install nuget package > dotnet add package DotNetElements.Wpf.Markdown --version <insert-latest-version-here>

  2. Add styles to App.xaml

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/DotNetElements.Wpf.Markdown;Component/Themes/Generic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
  1. Add xaml namespace
xmlns:markdown="clr-namespace:DotNetElements.Wpf.Markdown;assembly=DotNetElements.Wpf.Markdown"
  1. Add MarkdownTextBlock
<markdown:MarkdownTextBlock x:Name="MarkdownTextBlock" FontFamily="Segoe UI" />
  1. Set the Text property (binding is supported)
MarkdownTextBlock.Text = "Hello world from **DotNetElements.Wpf.Markdown**";
  1. To change the styling options for the different markdown blocks, add a customized MarkdownThemes.cs
MarkdownThemes myTheme = MarkdownThemes.Default;
myTheme.InlineCodeBackground = new SolidColorBrush(Colors.HotPink);

MarkdownTextBlock.Theme = myTheme;

Third party notices

The project is a port of the CommunityToolkit MarkdownTextBlock component to the WPF framework.

See CommunityToolkit/Labs-Windows/MarkdownTextBlock

The code block syntax highlighting uses ColorCode-Universal and a customized version of ColorCode-WPF

Product Compatible and additional computed target framework versions.
.NET net9.0-windows7.0 is compatible.  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
0.4.0 208 12/23/2024
0.3.0 168 12/22/2024
0.2.1 173 12/18/2024
0.1.0 175 12/17/2024