CommunityToolkit / CommunityToolkit/Labs-Windows
[MarkdownTextBlock] Support Extensions
- Dominant language
- C#
- Stars
- 482
- Forks
- 89
- PR merge metrics
- No merged PRs in 30d
Description
# Proposal: Extensions
The underlying parser `Markdig` supports extensions. Some of these come bundled with that package, such as Pipe Tables and Diagrams. Others can be added with extra code.
## Simple properties for built-in extensions
```xaml
```
We can ship with a few `UseFoo` properties that allow to configure the built-in extensions that end up both in the MarkdownPipeline and the Renderer. This makes it super easy to control which Markdown extensions get enabled without having to mess around with a MarkdownPipeline or any C# code.
## Custom extensions
Declaration in XAML:
```xaml
```
And C#, implementing a new interface we ship `IElement`:
```C#
class CustomElement : IElement
{
// Parsing
public void AddToPipeline(MarkdownPipelineBuilder pipelineBuilder)
{
pipelineBuilder.Extensions.Add(...);
}
// Rendering
public UWPObjectRenderer GetObjectRenderer() => new CustomRenderer();
}
```
With this approach, we can allow users to add arbitrary extensions on top of the control in a very simple and declarative manner. A quick glance at the XAML tells you all the built-in and custom extensions currently being used.
_Originally posted by @jcoc611-microsoft in https://github.com/CommunityToolkit/Labs-Windows/discussions/536#discussioncomment-11309494_
Contributor guide
Assessment
This issue has not been assessed yet.