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.
 
 
 
 
 
 

26 lines
612 B

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) => {
try {
const text = convert(html)
return text
.replaceAll(/&\w*;/g, "")
.replaceAll(/<!--\s?(.|\R|\s)*?-->/g, "")
.replaceAll(/<.*><\/.*>/g, "")
} catch (e) {
return ""
}
}
export const SHOULD_NOT_PARSE = "SHOULD_NOT_PARSE"