// Turns one markdown line into the words a reader sees: drops heading, list, quote and task // markers, image and link syntax (keeping link text), emphasis, inline code ticks and raw HTML. export function stripMarkdownSyntax(line: string): string { return line .replace(/<[^>]+>/g, ' ') .replace(/!\[[^\]]*\]\([^)]*\)/g, ' ') .replace(/\[([^\]]*)\]\([^)]*\)/g, '$1') .replace(/^\s{0,3}(#{1,6}\s+|>\s?|[-*+]\s+(\[[ xX]\]\s+)?|\d+[.)]\s+)/, '') .replace(/(\*\*|__|\*|_|~~|`|==|\$)/g, '') .replace(/\s+/g, ' ') .trim() }