Problem with rendering Local Image Path with whitespaces to HTML #460

Closed
opened 2026-01-29 14:37:21 +00:00 by claunia · 2 comments
Owner

Originally created by @1001binary on GitHub (May 7, 2021).

Hello,

I had problem with rendering local image Path with whitespace to HTML. It didn't work. After that, I tried to replace whitespaces in path by %20. It worked fine.

Problem

string text = "This is image: ![Image Alt Text](\\server\Image Files\test.png)"
Console.WriteLine(Markdig.Markdown.ToHtml(text));
// Output: "<p>This is image: ![Image Alt Text](\server\Image Files\test.png)</p>"

Worked ✔️

string text = "This is image: ![Image Alt Text](\\server\Image%20Files\test.png)"
Console.WriteLine(Markdig.Markdown.ToHtml(text));
// Output: "<p>This is image: <img src=""%5Cserver%5CImage%20Files%5Ctest.png"" alt=""Image Alt Text"" /></p>"

For image URL, it worked fine for both cases.

Best regards.

Originally created by @1001binary on GitHub (May 7, 2021). Hello, I had problem with rendering **local image Path** with whitespace to HTML. It didn't work. After that, I tried to replace whitespaces in path by %20. It worked fine. Problem :x: ``` string text = "This is image: ![Image Alt Text](\\server\Image Files\test.png)" Console.WriteLine(Markdig.Markdown.ToHtml(text)); // Output: "<p>This is image: ![Image Alt Text](\server\Image Files\test.png)</p>" ``` Worked :heavy_check_mark: ``` string text = "This is image: ![Image Alt Text](\\server\Image%20Files\test.png)" Console.WriteLine(Markdig.Markdown.ToHtml(text)); // Output: "<p>This is image: <img src=""%5Cserver%5CImage%20Files%5Ctest.png"" alt=""Image Alt Text"" /></p>" ``` For image URL, it worked fine for both cases. Best regards.
claunia added the question label 2026-01-29 14:37:21 +00:00
Author
Owner

@MihaZupan commented on GitHub (May 9, 2021):

This is essentially Example 485/486 of the spec:

The destination can only contain spaces if it is enclosed in pointy brackets

So to make the above example work: This is image: ![Image Alt Text](<\\server\Image Files\test.png>)

@MihaZupan commented on GitHub (May 9, 2021): This is essentially [Example 485/486 of the spec](https://spec.commonmark.org/0.29/#example-485): > The destination can only contain spaces if it is enclosed in pointy brackets So to make the above example work: `This is image: ![Image Alt Text](<\\server\Image Files\test.png>)`
Author
Owner

@1001binary commented on GitHub (Jun 10, 2021):

Sorry for my late response and also thank you for your response.

Even though it's correct as the spec, for MarkdownTextBlock in UWP I found something incompatible such as rendering path. I had to adapt this in UWP.

@1001binary commented on GitHub (Jun 10, 2021): Sorry for my late response and also thank you for your response. Even though it's correct as the spec, for MarkdownTextBlock in UWP I found something incompatible such as rendering path. I had to adapt this in UWP.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#460