An open API service indexing awesome lists of open source software.

https://github.com/giraugh/rehype-to-text

Rehype plugin to compile a rehype AST to text using `hast-util-to-text`
https://github.com/giraugh/rehype-to-text

Last synced: 3 months ago
JSON representation

Rehype plugin to compile a rehype AST to text using `hast-util-to-text`

Awesome Lists containing this project

README

        

# Rehype-to-text

Rehype plugin that compiles a hast tree to string using [`hast-util-to-text`](https://github.com/syntax-tree/hast-util-to-text)

## Usage

Install plugin with

```bash
npm i rehype-to-text
```

Then use `rehypeToText` as the last plugin in your `unified` chain.

```ts
import { unified } from "unified";
import rehypeParse from "rehype-parse";
import rehypeToText from "rehype-to-text";

const plainText = (
await unified()
.use(rehypeParse, { fragment: true })
.use(rehypeToText, { whitespace: "pre" })
.process(myHtml)
).toString();
```