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

Multiline base64 data is not folded correctly #12

Closed
keith-hall opened this issue Feb 22, 2017 · 8 comments
Closed

Multiline base64 data is not folded correctly #12

keith-hall opened this issue Feb 22, 2017 · 8 comments

Comments

@keith-hall
Copy link
Contributor

Data URIs encoded in Base64 may contain whitespace for human readability.

(From https://en.wikipedia.org/wiki/Data_URI_scheme#Syntax)

Example:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
    AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
    9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

    <style type="text/css">
    span {
        padding-left: 20px;
        background:white  url('data:image/png;base64,iVBORw0KGgoAA\
            AANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0l\
            EQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6\
            P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC') no-repeat scroll left top;
    }
    /* Backslashes at end of line - to continue character string
         at new line. */
    </style>
    <span>Test</span>
</body>
</html>

Currently the img only gets the first line (iVBORw0KGgoAAAANSUhEUgAAAAUA) folded (with base64fold_all_uris set to false), leaving the other lines unfolded. The uri(' in the CSS doesn't get folded at all.

CC @Kristinita re: sublimehq/sublime_text#513 (comment)

@DaQuirm
Copy link
Owner

DaQuirm commented Mar 2, 2017

Hello @keith-hall
I'm terribly sorry, but at the moment I don't have enough free time to investigate this issue (and the other one you opened).
It should be a simple regex fix, if you don't mind contributing 😉

@keith-hall keith-hall mentioned this issue Mar 2, 2017
@keith-hall
Copy link
Contributor Author

It turned out not to be massively simple (though it was certainly fun!), but I took the liberty of addressing one of your other outstanding issues while I was working on it, I hope you don't mind too much :)

@DaQuirm
Copy link
Owner

DaQuirm commented Mar 2, 2017

Thank you for your contribution! I'm glad it was fun to hack on this and you even added more tests! 😻

@DaQuirm DaQuirm closed this as completed Mar 2, 2017
@Kristinita
Copy link

@keith-hall , thanks for changes! But base64 data URI don't split automatically for human readability and Sublime Text syntax highlighting. We need to create feature request to Image2Base64 package or here?

Thanks.

@keith-hall
Copy link
Contributor Author

You'll want to create a feature request at the Image2Base64 package for that, or manually format the base64

@Kristinita
Copy link

@keith-hall , I don't understand: is it a question?

Thanks.

@keith-hall
Copy link
Contributor Author

@Kristinita Nope, it wasn't a question - I'm saying that this package, base64-fold, is for code folding only. In my opinion, it shouldn't be changed to alter the contents of the files in any way. As you are using the Image2Base64 plugin to generate the base64, it would make sense if you created a feature request there, so that it would wrap the base64 that it generates to a certain number of characters per line. Alternatively, or for existing base64 code inside your files, you could manually insert line breaks where you want them.

@Kristinita
Copy link

@keith-hall , my feature request.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants