Man page - he(1)

Packages contains this manual

    Package:  node-he
    apt-get install node-he
    Manuals in package:
    Documentations in package:

Manual


NAME

he โ€” encode/decode HTML entities just like a browser would

SYNOPSIS

he [ --escape string ]
[ --encode string ]
[ --encodeย --use-named-refsย --everythingย --allow-unsafe string ]
[ --decode string ]
[ --decodeย --attribute string ]
[ --decodeย --strict string ]
[ -v | --version ]
[ -h | --help ]

DESCRIPTION

he encodes/decodes HTML entities in strings just like a browser would.

OPTIONS
--escape

Take a string of text and escape it for use in text contexts in XML or HTML documents. Only the following characters are escaped: โ€˜&โ€˜, โ€˜<โ€˜, โ€˜>โ€˜, โ€˜"โ€˜, and โ€˜โ€™โ€˜.

--encode

Take a string of text and encode any symbols that arenโ€™t printable ASCII symbols and that can be replaced with character references. For example, it would turn โ€˜ยฉโ€˜ into โ€˜&#xA9;โ€˜, but it wouldnโ€™t turn โ€˜+โ€˜ into โ€˜&#x2B;โ€˜ since there is no point in doing so. Additionally, it replaces any remaining non-ASCII symbols with a hexadecimal escape sequence (e.g. โ€˜&#x1D306;โ€˜). The return value of this function is always valid HTML.

--encode --use-named-refs

Enable the use of named character references (like โ€˜&copy;โ€˜) in the output. If compatibility with older browsers is a concern, donโ€™t use this option.

--encode --everything

Encode every symbol in the input string, even safe printable ASCII symbols.

--encode --allow-unsafe

Encode non-ASCII characters only. This leaves unsafe HTML/XML symbols like โ€˜&โ€˜, โ€˜<โ€˜, โ€˜>โ€˜, โ€˜"โ€˜, and โ€˜โ€™โ€˜ intact.

--encode --decimal

Use decimal digits rather than hexadecimal digits for encoded character references, e.g. output โ€˜&#169;โ€˜ instead of โ€˜&#xA9;โ€˜.

--decode

Takes a string of HTML and decode any named and numerical character references in it using the algorithm described in the HTML spec.

--decode --attribute

Parse the input as if it was an HTML attribute value rather than a string in an HTML text content.

--decode --strict

Throw an error if an invalid character reference is encountered.

-v, --version

Print heโ€™s version.

-h, --help

Show the help screen.

EXIT STATUS

The he utility exits with one of the following values:

0

he did what it was instructed to do successfully; either it encoded/decoded the input and printed the result, or it printed the version or usage message.

1

he encountered an error.

EXAMPLES
he --escape โ€™<script>alert(1)</script>โ€™

Print an escaped version of the given string that is safe for use in HTML text contexts, escaping only โ€˜&โ€˜, โ€˜<โ€˜, โ€˜>โ€˜, โ€˜"โ€˜, and โ€˜โ€™โ€˜.

he --decode โ€™&copy;&#x1D306;โ€™

Print the decoded version of the given HTML string.

echoย โ€™&copy;&#x1D306;โ€™ย |ย he --decode

Print the decoded version of the HTML string that gets piped in.

BUGS

heโ€™s bug tracker is located at <https://github.com/mathiasbynens/he/issues>.

AUTHOR

Mathias Bynens <https://mathiasbynens.be/>

WWW

<https://mths.be/he> April 5, 2016 he (1)