Remove HTML from text with rehype-retext? #66
Answered
by
wooorm
kentcdodds
asked this question in
Q&A
-
Hi friends. This is what I've tried: async function stripHtml(htmlString: string) {
const {unified} = await import('unified')
const {default: parseHtml} = await import('rehype-parse')
const {default: rehypeRetext} = await import('rehype-retext')
const {default: retextStringify} = await import('retext-stringify')
const result = await unified()
.use(parseHtml)
.use(rehypeRetext)
.use(retextStringify)
.process(htmlString)
return result.value.toString()
}
async function go() {
const result = await stripHtml('<p>Hello</p>')
console.log(result)
}
void go() But I'm getting this:
I'm not sure what I need to do to get this to work 🙃 Based on what I understand of unified you give it a parser ( |
Beta Was this translation helpful? Give feedback.
Answered by
wooorm
Aug 21, 2021
Replies: 1 comment 3 replies
-
Yeah, I believe that should work fine, I think you found a bug! let me see |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
kentcdodds
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, I believe that should work fine, I think you found a bug! let me see