Giter Site home page Giter Site logo

Comments (7)

andrzejQ avatar andrzejQ commented on May 27, 2024 1

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));

nppMdP.tests.zip

from nppmarkdownpanel.

AlttiRi avatar AlttiRi commented on May 27, 2024

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.

from nppmarkdownpanel.

andrzejQ avatar andrzejQ commented on May 27, 2024

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

from nppmarkdownpanel.

andrzejQ avatar andrzejQ commented on May 27, 2024
        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()

from nppmarkdownpanel.

mohzy83 avatar mohzy83 commented on May 27, 2024

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.

from nppmarkdownpanel.

mohzy83 avatar mohzy83 commented on May 27, 2024
        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.

from nppmarkdownpanel.

mohzy83 avatar mohzy83 commented on May 27, 2024

fixed in release 0.7.2

from nppmarkdownpanel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.