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 doesn't support backticks in Link Text #2802

Open
michael-hawker opened this issue Feb 12, 2019 · 3 comments
Open

MarkdownTextBlock doesn't support backticks in Link Text #2802

michael-hawker opened this issue Feb 12, 2019 · 3 comments
Assignees
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ markdown 📑 Issues related to Markdown
Milestone

Comments

@michael-hawker
Copy link
Member

I'm submitting a...

  • Bug report

Current behavior

Trying to render the following valid markdown doesn't work:

[`Windows.UI.Composition` APIs](https://docs.microsoft.com/windows/uwp/composition/visual-layer)

Expected behavior

[`Windows.UI.Composition` APIs](https://docs.microsoft.com/windows/uwp/composition/visual-layer)

Windows.UI.Composition APIs

Minimal reproduction of the problem with instructions

  1. Open Sample App
  2. Open MarkDownTextBlock sample
  3. Add the following markdown to the textbox at the top:
[`Windows.UI.Composition` APIs](https://docs.microsoft.com/windows/uwp/composition/visual-layer)

Exception thrown in last line of RenderCodeRun trying to add inline to collection - System.ArgumentException: 'Value does not fall within the expected range.'

Environment

Nuget Package(s): 5.0.0

Package Version(s): 5.0.0

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [x] October 2018 Update (17763)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [x] October 2018 Update (17763)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [x] 2017 (version: )
- [ ] 2017 Preview (version: )

@Sergio0694
Copy link
Member

As mentioned in #2806 to @michael-hawker for the related issue, I can confirm that this too can be fixed (at least as a quick workaround) by replacing this line: https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/a722f171cac7959d8fb39d732c5951018a2e8c07/Microsoft.Toolkit.Uwp.UI.Controls/MarkdownTextBlock/Render/MarkdownRenderer.Inlines.cs#L581

With this code:

try
{
    localContext.InlineCollection.Add(inlineUIContainer);
}
catch (ArgumentException)
{
    // Fallback span
    Run run = new Run
    {
        Text = text.Text,
        FontFamily = InlineCodeFontFamily ?? FontFamily,
        Foreground = InlineCodeForeground ?? Foreground
    };

    // Additional formatting
    if (localContext.WithinItalics) run.FontStyle = FontStyle.Italic;
    if (localContext.WithinBold) run.FontWeight = FontWeights.Bold;

    // Add the fallback block
    localContext.InlineCollection.Add(run);
}

This will still render the code with the usual code font/foreground, and will just lack the additional background color (as it's just a Span). Still though, the visual difference is negligible, and at least this will work instead of just crashing and halting the whole rendering process.

@windowstoolkitbot
Copy link

This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

@Jay-o-Way
Copy link

following valid markdown

Micrsoft does advise against formatting text in a link, though...

@ghost ghost removed the no-recent-activity 📉 Open Issues that require attention label May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ markdown 📑 Issues related to Markdown
Projects
None yet
Development

No branches or pull requests

6 participants