-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Javascript option to preserve string newline or char codes #717
Comments
This was fixed in the latest release, a sequence of |
I have just disabled it for the moment. Why are you thinking that result from plain javascript minified
Actually my hex dump of the minified data output looks correct. The issue may elsewhere, but I am still seeing \r characters get replaced when turning on the minify . I'm using gohugo, so this might take a little more investigating. I'm importing a library and it is definitely getting changed wrong then.
I use typescript and other things so might be that. But only happens when minified is turned on. Using whatever version of that included in gohugo. Might not be a problem here, i can't reproduce.
However the module i'm importing is very complex. and includes lots of regexes that are not included in the test i've preformed. |
So when it transforms it within a javascript string. it needs to retain the \r characters? Your new version keeps the chars. i see. Ill try and run it |
Not sure if I understand the problem, please try the last version and tell me if you still have a problem. There is a difference between escape sequence (the characters '\' 'r' and '\' 'n') and literal (0x0D and 0x0A respectively) line terminators, but in some cases we may convert escape sequences into literals:
This is why this minifier tries to convert strings to template literals, since it may convert the line terminator sequences and save a byte for each one. |
Looks like it works. Using the latest version of your package. Node bindings. Are you assuming that all browsers support tagged literals. Thats fine for me, but thats a killer for many people. Might just be me having flash backs to supporting ie . Not sure
I have just tried with the latest hugo (0.127-extended) i can easily get. And i get the same result. There will be no issue if you replace with I'm using Iin the hex dumps. It transforms to incorrect code. Since it replaces the literal chars with whitespace characters. |
That looks correct. You can disable template literals by setting the
What do you mean, it works in your example above but not with Hugo? Perhaps they haven't updated the dependency? |
Yeah. So many versions and test cases linked to versions, it’s hard to say words. Lol. Sorry.
If i remember right. For one reason or another. You can no longer transform all the code into es5 properly using jsbuild in hugo. Cant remember why. Seems like everyone is moving away from it. This must be one of them. |
Just updated hugo and it seem to work. naturedamends/hugo@6f48198
|
I would like to preserve newline chars when in strings, such that I can write programs that operate on them. Currently it changes the output of the program.
\r\n
is being replaced with a single\n
. As a tagged literal with a new line char. I need the \rfor example:
is replaced with
which is completely different. Its char code is not 13, 10. Its simply 10
The text was updated successfully, but these errors were encountered: