criterios aceptacion: parsear Quill HTML a lista JSON + tooltip en dashboard

This commit is contained in:
2026-05-27 22:51:30 -05:00
parent 0a240ea146
commit 0339aa23f6
4 changed files with 49 additions and 5 deletions
+24
View File
@@ -22,3 +22,27 @@ export function extractFirstSentence(text: string, maxLen = 200): string {
export function stripHtmlTags(html: string): string {
return stripHtml(html)
}
export function parseQuillList(html: string): string[] {
if (!html) return []
const items: string[] = []
const liRegex = /<li[^>]*>([\s\S]*?)<\/li>/gi
let match
while ((match = liRegex.exec(html)) !== null) {
const text = match[1].replace(/<[^>]*>/g, '').trim()
if (text) items.push(text)
}
return items
}
export function criteriaToJson(html: string): string {
return JSON.stringify(parseQuillList(html))
}
export function criteriaFromJson(json: string): string[] {
try {
return JSON.parse(json)
} catch {
return []
}
}