Files
coopgo/node_modules/rehype-stringify/readme.md
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

184 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# rehype-stringify
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[**rehype**][rehype] plugin to serialize HTML.
[Compiler][] for [**unified**][unified].
Stringifies [**hast**][hast] syntax trees to HTML.
Used in the [**rehype** processor][processor] but can be used on its own as
well.
If youre in a browser, trust the content, and value a smaller bundle size, use
[`rehype-dom-stringify`][rehype-dom-stringify] instead.
## Sponsors
<!--lint ignore no-html maximum-line-length-->
<table>
<tr valign="top">
<td width="20%" align="center">
<a href="https://zeit.co"><img src="https://avatars1.githubusercontent.com/u/14985020?s=400&v=4"></a>
<br><br>🥇
<a href="https://zeit.co">ZEIT</a>
</td>
<td width="20%" align="center">
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=400&v=4"></a>
<br><br>🥇
<a href="https://www.gatsbyjs.org">Gatsby</a>
</td>
<td width="20%" align="center">
<a href="https://www.netlify.com"><img src="https://avatars1.githubusercontent.com/u/7892489?s=400&v=4"></a>
<br><br>🥇
<a href="https://www.netlify.com">Netlify</a>
</td>
<td width="20%" align="center">
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=400&v=4"></a>
<br><br>
<a href="https://www.holloway.com">Holloway</a>
</td>
<td width="20%" align="center">
<br><br><br><br>
<a href="https://opencollective.com/unified"><strong>You?</strong>
</td>
</tr>
</table>
[**Read more about the unified collective on Medium »**][announcement]
## Install
[npm][]:
```sh
npm install rehype-stringify
```
## Use
```js
var unified = require('unified')
var createStream = require('unified-stream')
var parse = require('rehype-parse')
var stringify = require('rehype-stringify')
var processor = unified()
.use(parse)
.use(stringify, {
quoteSmart: true,
closeSelfClosing: true,
omitOptionalTags: true,
entities: {useShortestReferences: true}
})
process.stdin.pipe(createStream(processor)).pipe(process.stdout)
```
## API
### `processor.use(stringify[, options])`
Configure `processor` to serialize [**hast**][hast] syntax trees to HTML.
###### `options`
Options can be passed when using `processor.use(stringify, options)` or with
`processor.data('settings', options)`.
All settings are passed to [`hast-util-to-html`][hast-util-to-html].
## Security
As **rehype** works on HTML, and improper use of HTML can open you up to a
[cross-site scripting (XSS)][xss] attack, use of rehype can also be unsafe.
Use [`rehype-sanitize`][sanitize] to make the tree safe.
## Contribute
See [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways
to get started.
See [`support.md`][support] for ways to get help.
Ideas for new plugins and tools can be posted in [`rehypejs/ideas`][ideas].
A curated list of awesome rehype resources can be found in [**awesome
rehype**][awesome].
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://img.shields.io/travis/rehypejs/rehype.svg
[build]: https://travis-ci.org/rehypejs/rehype
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype.svg
[coverage]: https://codecov.io/github/rehypejs/rehype
[downloads-badge]: https://img.shields.io/npm/dm/rehype-stringify.svg
[downloads]: https://www.npmjs.com/package/rehype-stringify
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-stringify.svg
[size]: https://bundlephobia.com/result?p=rehype-stringify
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/rehype
[health]: https://github.com/rehypejs/.github
[contributing]: https://github.com/rehypejs/.github/blob/master/contributing.md
[support]: https://github.com/rehypejs/.github/blob/master/support.md
[coc]: https://github.com/rehypejs/.github/blob/master/code-of-conduct.md
[ideas]: https://github.com/rehypejs/ideas
[awesome]: https://github.com/rehypejs/awesome-rehype
[license]: https://github.com/rehypejs/rehype/blob/master/license
[author]: https://wooorm.com
[npm]: https://docs.npmjs.com/cli/install
[unified]: https://github.com/unifiedjs/unified
[rehype]: https://github.com/rehypejs/rehype
[processor]: https://github.com/rehypejs/rehype/tree/master/packages/rehype
[compiler]: https://github.com/unifiedjs/unified#processorcompiler
[hast]: https://github.com/syntax-tree/hast
[hast-util-to-html]: https://github.com/syntax-tree/hast-util-to-html#tohtmlnode-options
[rehype-dom-stringify]: https://github.com/rehypejs/rehype-dom/tree/master/packages/rehype-dom-stringify
[announcement]: https://medium.com/unifiedjs/collectively-evolving-through-crowdsourcing-22c359ea95cc
[sanitize]: https://github.com/rehypejs/rehype-sanitize
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting