Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkdownTextBlock: add alternative to Text property to pass in a MarkdownDocument to the control #596

Open
jcoc611-microsoft opened this issue Nov 14, 2024 · 1 comment

Comments

@jcoc611-microsoft
Copy link

Currently, the only way to set the content of a MarkdownTextBlock is via the Text property, which internally uses Markdown.Parse to convert to a MarkdownDocument. It would be nice to also allow users to pass in an existing MarkdownDocument as an alternative.
 
Example:

<controls:MarkdownTextBlock
  MarkdownDocument="{x:Bind Doc, Mode=OneTime}" />

Benefits:

  • Users can insert arbitrary logic after Markdown.Parse(...), such as mutating the MarkdownDocument tree with decorations
  • Users can provide a custom Markdown pipeline
  • Users can preserve the MarkdownDocument for other operations, such as copying the content to HTML with Markdown.ToHtml(...)
jcoc611-microsoft pushed a commit to jcoc611-microsoft/Labs-Windows that referenced this issue Nov 14, 2024
@jcoc611-microsoft
Copy link
Author

jcoc611-microsoft commented Nov 29, 2024

Thinking about it more, I think it is actually better to expose the control's MarkdownDocument rather than allowing users to pass one in.

Users can insert arbitrary logic after Markdown.Parse(...)

This should only be done via Markdig extensions. We will provide different extensibility mechanisms which also allow for implementing custom renderers for the outputs of the extensions.

Users can provide a custom Markdown pipeline

This is not really desired in general, other than extensions.

Users can preserve the MarkdownDocument for other operations

The control owns the MarkdownDocument and users can just access it directly

TBD: add an event for when parsing is done (before this, accessing MarkdownDocument is not valid, and it would be null)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant