WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

MarkdownTextBlock not rendering HTML codes

Open savian-net opened this issue 3 years ago • 4 comments

Describe the bug

HTML hex codes are not being rendered when using x:Bind in MarkdownTextBlock.

Regression

No response

Reproducible in sample app?

  • [ ] This bug can be reproduced in the sample app.

Steps to reproduce

Code: 

<controls:MarkdownTextBlock x:Name="HomePageOverview" Grid.Column="0" Text="a Microsoft&#xAE; environment"/>

Renders the HTML code as a Copyright symbol.

<controls:MarkdownTextBlock x:Name="HomePageOverview" Grid.Column="0" Text="{x:Bind OverviewText}"/>
....
Code behind:

OverviewText = "a Microsoft&#xAE; environment";

And bind the same raw text, it does not render the copyright symbol.

Expected behavior

HTML codes should be rendered when bound from code-behind. HTML tags should also be interpreted correctly (like

). Instead, raw text is displayed vs being rendered.

Screenshots

No response

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [X] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [X] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Nuget packages

<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />

Additional context

No response

Help us help you

No.

savian-net avatar Dec 01 '22 05:12 savian-net

Hello savian-net, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Dec 01 '22 05:12 ghost

@savian-net our parser doesn't support general decimal/hex codes for characters. It does do name codes though: https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/main/UnitTests/UnitTests.UWP/Markdown/Parse/ParagraphTests.cs#L128

So you can use &copy; for this particular scenario.

We'd like to move to Markdig for parsing in the future, see #4663 which would support this scenario. In the meantime we don't have plans to update the existing MarkdownTextBlock control. We're still planning our next release and figuring out which controls to bring over to the new infrastructure.

michael-hawker avatar Dec 08 '22 20:12 michael-hawker

Anything you do will help. I know it is an open source imitative. It is expected that HTML codes are recognized. If an engine change is needed, I get that. I am locked into WinUI so I can't backtrack. For now, I just coded around it but any help is appreciated.

savian-net avatar Dec 09 '22 04:12 savian-net