Searching.ton
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
561 B

2 years ago
import textversion from "textversionjs"
const convert = (html: string) =>
textversion(html, {
linkProcess: function (href, linkText) {
return linkText || "HUJ"
},
imgProcess: function (src, alt) {
return alt
},
headingStyle: "linebreak",
listStyle: "linebreak",
})
export const htmlToText = (html: string) => {
const text = convert(html)
return text
.replaceAll(/&\w*;/g, "")
.replaceAll(/<!--\s?(.|\R|\s)*?-->/g, "")
.replaceAll(/<.*><\/.*>/g, "")
}
export const SHOULD_NOT_PARSE = "SHOULD_NOT_PARSE"