Files
agent-desk-ng/web/lib/support-article.ts

14 lines
460 B
TypeScript

export function articleHeadingId(title: string, index: number) {
const normalized = title.trim().toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-|-$/g, "")
return `section-${index + 1}-${normalized || "heading"}`
}
export function markdownHeadingText(value: string) {
return value
.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1")
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
.replace(/<[^>]+>/g, "")
.replace(/[*_~`]/g, "")
.trim()
}