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.
 
 
 
 
 
 

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