limpiar HTML de descripciones KAPPA + sync proyectos a Turso
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
export function stripHtml(html: string): string {
|
||||
if (!html) return ''
|
||||
return html
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'")
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
}
|
||||
|
||||
export function extractFirstSentence(text: string, maxLen = 200): string {
|
||||
const cleaned = stripHtml(text)
|
||||
const match = cleaned.match(/^[^.!?]+[.!?]/)
|
||||
if (match) return match[0].slice(0, maxLen)
|
||||
return cleaned.slice(0, maxLen)
|
||||
}
|
||||
|
||||
export function stripHtmlTags(html: string): string {
|
||||
return stripHtml(html)
|
||||
}
|
||||
Reference in New Issue
Block a user