js-beautify
js-beautify copied to clipboard
syntax error in beautified code when using "unescape-strings" (Unescape printable chars encoded as \xNN or \uNNNN)
Description
when using the "unescape-strings" (Unescape printable chars encoded as \xNN or \uNNNN) feature, some encoded characters cause a new line to be created, which is a syntax error in the code
Input
The code looked like this before beautification:
let encodedString = '\u2028';
let encodedString2 = '\u2029';
console.log(encodedString, encodedString2);
Expected Output
The code should have looked like this after beautification:
let encodedString = '
';
let encodedString2 = '
';
console.log(encodedString, encodedString2);
Actual Output
The code actually looked like this after beautification:
let encodedString = '
';
let encodedString2 = '
';
console.log(encodedString, encodedString2);
Steps to Reproduce
- go to https://beautifier.io/
- enable "Unescape printable chars encoded as \xNN or \uNNNN"
- paste in code below:
let encodedString = '\u2028';
let encodedString2 = '\u2029';
console.log(encodedString, encodedString2);
- error in beautified code
Environment
OS: Web
Settings
Example:
{
"indent_size": "4",
"indent_char": " ",
"max_preserve_newlines": "5",
"preserve_newlines": true,
"keep_array_indentation": false,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "end-expand",
"space_before_conditional": false,
"unescape_strings": true,
"jslint_happy": false,
"end_with_newline": false,
"wrap_line_length": "0",
"indent_inner_html": false,
"comma_first": false,
"e4x": false,
"indent_empty_lines": false
}