Projekt

Obecné

Profil

Stáhnout (2.82 KB) Statistiky
| Větev: | Revize:
1
.Dd May 13, 2016
2
.Dt jsesc 1
3
.Sh NAME
4
.Nm jsesc
5
.Nd escape strings for use in JavaScript string literals
6
.Sh SYNOPSIS
7
.Nm
8
.Op Fl s | -single-quotes Ar string
9
.br
10
.Op Fl d | -double-quotes Ar string
11
.br
12
.Op Fl w | -wrap Ar string
13
.br
14
.Op Fl e | -escape-everything Ar string
15
.br
16
.Op Fl 6 | -es6 Ar string
17
.br
18
.Op Fl l | -lowercase-hex Ar string
19
.br
20
.Op Fl j | -json Ar string
21
.br
22
.Op Fl p | -object Ar string
23
.br
24
.Op Fl p | -pretty Ar string
25
.br
26
.Op Fl v | -version
27
.br
28
.Op Fl h | -help
29
.Sh DESCRIPTION
30
.Nm
31
escapes strings for use in JavaScript string literals while generating the shortest possible valid ASCII-only output.
32
.Sh OPTIONS
33
.Bl -ohang -offset
34
.It Sy "-s, --single-quotes"
35
Escape any occurrences of ' in the input string as \\', so that the output can be used in a JavaScript string literal wrapped in single quotes.
36
.It Sy "-d, --double-quotes"
37
Escape any occurrences of " in the input string as \\", so that the output can be used in a JavaScript string literal wrapped in double quotes.
38
.It Sy "-w, --wrap"
39
Make sure the output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be specified using the
40
.Ar -s | --single-quotes
41
or
42
.Ar -d | --double-quotes
43
settings.
44
.It Sy "-6, --es6"
45
Escape any astral Unicode symbols using ECMAScript 6 Unicode code point escape sequences.
46
.It Sy "-e, --escape-everything"
47
Escape all the symbols in the output, even printable ASCII symbols.
48
.It Sy "-j, --json"
49
Make sure the output is valid JSON. Hexadecimal character escape sequences and the \\v or \\0 escape sequences will not be used. Setting this flag enables the
50
.Ar -d | --double-quotes
51
and
52
.Ar -w | --wrap
53
settings.
54
.It Sy "-o, --object"
55
Treat the input as a JavaScript object rather than a string. Accepted values are flat arrays containing only string values, and flat objects containing only string values.
56
.It Sy "-p, --pretty"
57
Pretty-print the output for objects, using whitespace to make it more readable. Setting this flag enables the
58
.It Sy "-l, --lowercase-hex"
59
Use lowercase for alphabetical hexadecimal digits in escape sequences.
60
.Ar -o | --object
61
setting.
62
.It Sy "-v, --version"
63
Print jsesc's version.
64
.It Sy "-h, --help"
65
Show the help screen.
66
.El
67
.Sh EXIT STATUS
68
The
69
.Nm jsesc
70
utility exits with one of the following values:
71
.Pp
72
.Bl -tag -width flag -compact
73
.It Li 0
74
.Nm
75
successfully escaped the given string and printed the result.
76
.It Li 1
77
.Nm
78
wasn't instructed to escape anything (for example, the
79
.Ar --help
80
flag was set); or, an error occurred.
81
.El
82
.Sh EXAMPLES
83
.Bl -ohang -offset
84
.It Sy "jsesc 'foo bar baz'"
85
Print an escaped version of the given string.
86
.It Sy echo\ 'foo bar baz'\ |\ jsesc
87
Print an escaped version of the string that gets piped in.
88
.El
89
.Sh BUGS
90
jsesc's bug tracker is located at <https://github.com/mathiasbynens/jsesc/issues>.
91
.Sh AUTHOR
92
Mathias Bynens <https://mathiasbynens.be/>
93
.Sh WWW
94
<https://mths.be/jsesc>
    (1-1/1)