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`
- Host: GitHub
- URL: https://github.com/giraugh/rehype-to-text
- Owner: giraugh
- Created: 2024-02-25T23:30:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-26T00:02:11.000Z (about 1 year ago)
- Last Synced: 2025-02-14T17:53:30.134Z (3 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/rehype-to-text
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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();
```