1JavaScript::Beautifier(U3s)er Contributed Perl DocumentatJiaovnaScript::Beautifier(3)
2
3
4

NAME

6       JavaScript::Beautifier - Beautify Javascript (beautifier for
7       javascript)
8

SYNOPSIS

10           use JavaScript::Beautifier qw/js_beautify/;
11
12           my $pretty_js = js_beautify( $js_source_code, {
13               indent_size => 4,
14               indent_character => ' ',
15           } );
16

DESCRIPTION

18       This module is mostly a Perl-rewrite of
19       <http://github.com/einars/js-beautify/tree/master/beautify.js>
20
21       You can check it through <http://jsbeautifier.org/>
22

FUNCTIONS

24       $js_source_code = <<'EOF';
25         a = 12;
26         {return '\\w+';} EOF
27
28   js_beautify( $js_source_code, $opts );
29       Beautify javascript source code contained in a string with the included
30       options, described below.
31
32       Options
33
34       indent_size
35       indent_character
36           if you prefer Tab than Space, try:
37
38               {
39                   indent_size => 1,
40                   indent_character => "\t",
41               }
42
43       preserve_newlines
44           Default is 1
45
46               my $in = "var\na=dont_preserve_newlines";
47               my $out = "var a = dont_preserve_newlines";
48               my $js = js_beautify( $in, { preserve_newlines => 0 } );
49               # $out eq $js
50               $in = "var\na=do_preserve_newlines";
51               $out = "var\na = do_preserve_newlines";
52               $js = js_beautify( $in, { preserve_newlines => 1 } );
53               # $out eq $js
54
55       space_after_anon_function
56           Default is 0
57

AUTHOR

59       Fayland Lam, "<fayland at gmail.com>"
60
62       Copyright 2008-2018 Fayland Lam, all rights reserved.
63
64       This program is free software; you can redistribute it and/or modify it
65       under the same terms as Perl itself.
66
67
68
69perl v5.30.0                      2019-07-26         JavaScript::Beautifier(3)
Impressum