Subject: | Beautifier.pm |
Date: | Mon, 19 Mar 2018 22:22:46 +0100 |
To: | bug-JavaScript-Beautifier [...] rt.cpan.org |
From: | "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net> |
Hello,
Double backslashes will be erroneously cut now. http://jsbeautifier.org/
does not show this error of course.
For example, a line:
"{return'\\w+'};";
Will be erroneously translated to:
"{return '\w+'};";
To avoid this, code has to be modified as follows:
Old code (line 26, ...):
sub js_beautify {
my ( $js_source_code, $opts ) = @_;
$opt_indent_size = $opts->{indent_size} || 4;
New code (line 26, ...):
sub js_beautify {
my ( $js_source_code, $opts ) = @_;
$js_source_code =~ s/\\/\\\\/g; # prevent \\ -> \ tktk
$opt_indent_size = $opts->{indent_size} || 4;
I tested the modification, and it works properly.
Thank you for the correction in advance.