Closed AlttiRi closed 1 year ago
UPD.
Not only a space character, but other chars too (which should be encoded).
For example, if I have [image] example 1—1.png
then I should include it as %5Bimage%5D%20example%201%E2%80%941.png
.
This is a bug under IE/Edge with local file links containing non US-ASCII chars, with escape chars in URL with %..
Can this be inserted in MarkdownPreviewForm.cs
in line 128?
//Unescape local file links containing non US - ASCII chars because of IE/Edge bug
//But unescape all is probably too much...
resultForBrowser = Uri.UnescapeDataString(resultForBrowser);
Tests in Zip: test nonAscii path.zip
public static MarkdownPipelineBuilder UseNonAsciiNoEscape(this MarkdownPipelineBuilder pipeline);
// Uses this extension to disable URI escape with % characters for non-US-ASCII
// characters in order to workaround a bug under IE/Edge with local file links containing
// non US-ASCII chars. DO NOT USE OTHERWISE.
but inserting it in MarkdigMarkdownGenerator.cs
doesn't work:
public string ConvertToHtml(string markDownText, string filepath)
{
...
var pipeline = new MarkdownPipelineBuilder()
.UseNonAsciiNoEscape()
This is a bug under IE/Edge with local file links containing non US-ASCII chars, with escape chars in URL with
%..
Can this be inserted in
MarkdownPreviewForm.cs
in line 128?//Unescape local file links containing non US - ASCII chars because of IE/Edge bug //But unescape all is probably too much... resultForBrowser = Uri.UnescapeDataString(resultForBrowser);
I think its no good idea to unescape the complete document. This can lead to undesired side effects. It would be better to unescape only src attribute of img tags.
public static MarkdownPipelineBuilder UseNonAsciiNoEscape(this MarkdownPipelineBuilder pipeline); // Uses this extension to disable URI escape with % characters for non-US-ASCII // characters in order to workaround a bug under IE/Edge with local file links containing // non US-ASCII chars. DO NOT USE OTHERWISE.
but inserting it in
MarkdigMarkdownGenerator.cs
doesn't work:public string ConvertToHtml(string markDownText, string filepath) { ... var pipeline = new MarkdownPipelineBuilder() .UseNonAsciiNoEscape()
Doesn't work for me neither. Actually this setting should produce the desired result.
This can be inserted in MarkdownPreviewForm.cs
in line 128 (desperate solution).
(I have created pull request).
//using System.Text.RegularExpressions;
//string inp = " * %25%20x : `<img src=\"file:///C:/tmp/test%20nonAscii%20path/A%C4%85C%C4%87E/A%C4%84%2520(2).png\" />`";
//outp: * %25%20x : `<img src="file:///C:/tmp/test nonAscii path/AąCćE/AĄ%20(2).png" />`
Regex regex = new Regex("src=\"file:///[^\"]+");
resultForBrowser = regex.Replace(resultForBrowser, m => Uri.UnescapeDataString(m.Value));
fixed in release 0.7.2
It should display a local image that has a space character
` in the filename if the image is included with escaping (
%20`).For example, I have an image
123 4.png
.I include it to
.md
file with:![](123%203.png "")
.It works fine, for example, both in GitHub and in IntelliJ IDEA. But this plugin does not work with this case.