|
| 1 | +## About |
| 2 | + |
| 3 | +This project provides a simple markdown renderer for WPF. |
| 4 | +This implementation uses the popular [Markdig](https://github.com/xoofx/markdig) library for parsing. |
| 5 | +At the current state, not all markdown features are supported. Styling options for the markdown blocks need to be improved. |
| 6 | + |
| 7 | +### Supported features: |
| 8 | +-[x] Paragraphs |
| 9 | +-[x] InlineEmphasis |
| 10 | +-[x] Headings |
| 11 | +-[x] InlineCode |
| 12 | +-[x] InlineHyperlink |
| 13 | +-[x] Lists (unordered & ordered) |
| 14 | +-[x] ThematicBreak |
| 15 | + |
| 16 | +### Features to implement: |
| 17 | +-[ ] CodeBlocks |
| 18 | +-[ ] Images |
| 19 | +-[ ] Tables |
| 20 | + |
| 21 | +## Recommended setup |
| 22 | + |
| 23 | +1. Install nuget package `> dotnet add package DotNetElements.Wpf.Markdown --version <insert-latest-version-here>` |
| 24 | + |
| 25 | +2. Add styles to `App.xaml` |
| 26 | +```xaml |
| 27 | +<Application.Resources> |
| 28 | + <ResourceDictionary> |
| 29 | + <ResourceDictionary.MergedDictionaries> |
| 30 | + <ResourceDictionary Source="pack://application:,,,/DotNetElements.Wpf.Markdown;Component/Themes/Generic.xaml" /> |
| 31 | + </ResourceDictionary.MergedDictionaries> |
| 32 | + </ResourceDictionary> |
| 33 | +</Application.Resources> |
| 34 | +``` |
| 35 | + |
| 36 | +2. Add xaml namespace |
| 37 | +```xaml |
| 38 | +xmlns:markdown="clr-namespace:DotNetElements.Wpf.Markdown;assembly=DotNetElements.Wpf.Markdown" |
| 39 | +``` |
| 40 | + |
| 41 | +3. Add `MarkdownTextBlock` |
| 42 | +```xaml |
| 43 | +<markdown:MarkdownTextBlock x:Name="MarkdownTextBlock" FontFamily="Segoe UI" /> |
| 44 | +``` |
| 45 | + |
| 46 | +4. Set the `Text` property (binding is supported) |
| 47 | +```cs |
| 48 | +MarkdownTextBlock.Text = "Hello world from **DotNetElements.Wpf.Markdown**"; |
| 49 | +``` |
| 50 | + |
| 51 | +5. To change the styling options for the different markdown blocks, add a customized `MarkdownThemes.cs` |
| 52 | +```cs |
| 53 | +MarkdownThemes myTheme = MarkdownThemes.Default; |
| 54 | +myTheme.InlineCodeBackground = new SolidColorBrush(Colors.HotPink); |
| 55 | + |
| 56 | +MarkdownConfig myConfig = MarkdownConfig.Default; |
| 57 | +myConfig.Themes = myTheme; |
| 58 | + |
| 59 | +MarkdownTextBlock.Config = myConfig; |
| 60 | +``` |
| 61 | + |
| 62 | +## Third party notices |
| 63 | + |
| 64 | +The project is a port of the CommunityToolkit MarkdownTextBlock component to the WPF framework |
| 65 | +see [CommunityToolkit/Labs-Windows/MarkdownTextBlock](https://github.com/CommunityToolkit/Labs-Windows/tree/a37acd33031037daa4d39318e3a10741b1c046ea/components/MarkdownTextBlock) |
0 commit comments