giraugh / rehype-to-text

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

Home Page:https://www.npmjs.com/package/rehype-to-text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rehype-to-text

Rehype plugin that compiles a hast tree to string using hast-util-to-text

Usage

Install plugin with

npm i rehype-to-text

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

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();

About

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

https://www.npmjs.com/package/rehype-to-text


Languages

Language:JavaScript 67.8%Language:TypeScript 32.2%