Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

[Discussion] Do we use a .NET Markdown Parser Library instead of our own? #3200

Closed

Description

@michael-hawker

Describe the problem this feature would solve

We have a lot of overhead for the MarkdownTextBlock supporting Markdown via our own Markdown parser. It may make more sense to refactor on top of a .NET Standard library that's maintained by a larger community, like Markdig.

This however, would require updating our MarkdownRenderer code to do all the construction from the AST.

Describe the solution

Take a dependency on a markdown parser instead of maintaining our own.

Additional context

We were thinking as part of #3062 to separate out the MarkdownTextBlock anyway, as it has a lot of dependencies, so this could also contribute to that effort as well to remove the need for the dependency on Microsoft.Toolkit.Parsers.

If we do this swap, we should convert all of our existing Unit Tests on the Parser to instead test the Renderer and check the translation between the Markdown text scenario and the UI Element tree construction.

This may also just mean we can get rid of the Microsoft.Toolkit.Parsers package entirely if we find another open source C# based RSS parser as we don't use that elsewhere in the toolkit currently.

Requirements

Activity

  1. added this to the 7.0 milestone on Mar 26, 2020
  2. ghost added
    for-review 📖To evaluate and validate the Issues or PR
    on Mar 26, 2020
  3. 14 remaining items

  4. LokiMidgard commented on Apr 4, 2020

    @LokiMidgard

    I would like to see that the used parser could be exchangeable. E.g. hidden behind some interfaces. Including a default Implementation that is CommonMark compatible.

    There are a bunch of different Markdown flavors out there already in use. If I start from scratch, I can use a flavor that is supported by this library. But if I consume the markdown from another source I don't control and it does not works with the implementation we choose I'm screwed.

    Since this library is probably the way to go when rendering markdown in WinUi, it should be a little flexible.

  5. LokiMidgard commented on Apr 4, 2020

    @LokiMidgard

    If we do this swap, we should convert all of our existing Unit Tests on the Parser to instead test the Renderer and check the translation between the Markdown text scenario and the UI Element tree construction.

    If you convert the existing Unit Tests, please consider DataRowAttribute for thinks like different Mail addresses. It was really painfull to find the mail addresses that were not working in the test. And every mail address after the failing one was not testst.

  6. michael-hawker commented on Apr 6, 2020

    @michael-hawker
    MemberAuthor

    @LokiMidgard as a quick fix for the existing unit tests I did in #3207 to better understand these problems, I did use the DataRowAttribute.

    I know it's going to be a lot of work already to flip over to another implementation for the rendering, there is some tight coupling there, so I'm not sure how feasible it'd be to abstract again to support different parsers. Markdig does seem rather flexible with extensions, so I certainly think we should still have call-outs for customization, but I don't think a whole abstraction for parsing below the rending would be warranted?

    @MihaZupan what has been your experience with the Markdown community on these subjects of the different Markdown flavors?

  7. michael-hawker commented on Aug 6, 2020

    @michael-hawker
    MemberAuthor

    I also want to bring up the issue of #268 again about HTML content (thinking snippets or other things), I just encountered this need again with Teams messages from the Microsoft Graph with our GraphPresenter control.

    As part of this parser swap, could it make sense to have the renderer be more generalized to support a different parser for display or would these just be two parallel efforts?

  8. michael-hawker commented on Aug 6, 2020

    @michael-hawker
    MemberAuthor

    Actually just found this Xamarin solution for HTMLLabel, will test that out for my scenario. :)

  9. modified the milestones: 7.0, 7.1 on Jan 5, 2021
  10. ghost removed this from the 7.1 milestone on Jan 5, 2021
  11. deleted a comment from on Mar 11, 2021
  12. deleted a comment from on Mar 11, 2021
  13. michael-hawker commented on Mar 11, 2021

    @michael-hawker
    MemberAuthor

    Well @Kyaa-dost the bot works! 🎉🎉🎉

    image

    We just have to be careful about referencing other issues in the release notes...

    Looks like it also only picks up #0000 for Issue numbers and not PRs, so may have to investigate the release note generators a bit more.

  14. Kyaa-dost commented on Mar 11, 2021

    @Kyaa-dost
    Contributor

    Thanks @michael-hawker! Will certainly check it out!

  15. added this to the future milestone on Apr 29, 2021
  16. locked and limited conversation to collaborators on Jul 29, 2022
  17. converted this issue into a discussion #4663 on Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions