ai-tube / src /lib /utils /stripHtml.ts
jbilcke's picture
working to improve the clap format
f42b4a1
raw
history blame
455 Bytes
export function stripHtml(input: string) {
try {
return (
`${input || ""}`
.replace(/<style[^>]*>.*<\/style>/g, '')
// Remove script tags and content
.replace(/<script[^>]*>.*<\/script>/g, '')
// Remove all opening, closing and orphan HTML tags
.replace(/<[^>]+>/g, '')
// Remove leading spaces and repeated CR/LF
.replace(/([\r\n]+ +)+/g, '')
)
} catch (err) {
return ""
}
}