'use client'; interface PrdViewerProps { content: string; } /** * Lightweight markdown-to-HTML renderer for PRD content. * Supports headings, bold, italic, inline code, code blocks, and lists. * No external dependency — keeps bundle size minimal. */ function renderMarkdown(md: string): string { let html = md // Escape HTML entities first to prevent XSS .replace(/&/g, '&') .replace(//g, '>'); // Code blocks (must run before inline code) html = html.replace(/```[\w]*\n?([\s\S]*?)```/g, (_match, code: string) => { return `
${code.trim()}`;
});
// Headings
html = html.replace(
/^#### (.+)$/gm,
'$1',
);
// Paragraphs — wrap lines that aren't already wrapped in a block element
const lines = html.split('\n');
const result: string[] = [];
for (const line of lines) {
const trimmed = line.trim();
if (trimmed === '') {
result.push('');
} else if (
trimmed.startsWith('