micromark-util-encode

micromark utility to encode dangerous html characters

Usage no npm install needed!

<script type="module">
  import micromarkUtilEncode from 'https://cdn.skypack.dev/micromark-util-encode';
</script>

README

micromark-util-encode

Build Coverage Downloads Size Sponsors Backers Chat

micromark utility to encode dangerous html characters.

Contents

Install

npm:

npm install micromark-util-encode

Use

import {encode} from 'micromark-util-encode'

encode('<3') // '&lt;3'

API

This module exports the following identifiers: encode. There is no default export.

encode(value)

Encode only the dangerous HTML characters.

This ensures that certain characters which have special meaning in HTML are dealt with. Technically, we can skip > and " in many cases, but CM includes them.

Parameters
  • value (string) — Value to encode.
Returns

string — Encoded value.

Security

See security.md in micromark/.github for how to submit a security report.

Contribute

See contributing.md in micromark/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer