$1')
// Bold + Italic
.replace(/\*\*\*([^*]+)\*\*\*/g, '$1')
.replace(/___([^_]+)___/g, '$1')
// Bold
.replace(/\*\*([^*]+)\*\*/g, '$1')
.replace(/__([^_]+)__/g, '$1')
// Italic
.replace(/\*([^*]+)\*/g, '$1')
.replace(/\b_([^_]+)_\b/g, '$1')
// Strikethrough
.replace(/~~([^~]+)~~/g, '${codeContent}`);
inCodeBlock = false;
codeBlockLines = [];
codeBlockLang = '';
} else {
closeList();
inCodeBlock = true;
codeBlockLang = trimmed.substring(3).trim();
codeBlockLines = [];
}
continue;
}
if (inCodeBlock) {
codeBlockLines.push(rawLine);
continue;
}
// Markdown result tables need real cells to remain readable in reports.
if (trimmed.includes('|') && i + 1 < rawLines.length
&& /^\s*\|?\s*:?-{3,}:?(?:\s*\|\s*:?-{3,}:?)*\s*\|?\s*$/.test(rawLines[i + 1])) {
closeList();
const cells = (line: string) => line.trim().replace(/^\|/, '').replace(/\|$/, '').split('|');
const headings = cells(rawLine);
result.push('| ${formatInlineMarkdown(cell.trim())} | `).join('') + '
|---|
| ${formatInlineMarkdown((row[index] || '').trim())} | `).join('') + '
${quoteContent}`); continue; } // 5. Unordered List: - item or * item const ulMatch = rawLine.match(/^(\s*)([\*\-])\s+(.*)$/); if (ulMatch) { if (currentListType !== 'ul') { closeList(); currentListType = 'ul'; result.push('
${codeContent}`);
}
closeList();
return result.join('\n');
}