import { marked } from 'marked'; // Configure marked marked.setOptions({ breaks: true, gfm: true, // GitHub Flavored Markdown pedantic: false }); export class MarkdownService { /** * Convert markdown to HTML */ static render(markdown) { try { if (!markdown) return ''; // Sanitize: remove script tags and dangerous HTML const sanitized = this.sanitize(markdown); // Render markdown const html = marked(sanitized); return html; } catch (err) { console.error('❌ Markdown render error:', err); return `
Error rendering content
`; } } /** * Sanitize markdown to prevent XSS */ static sanitize(markdown) { if (!markdown) return ''; // Remove script tags let sanitized = markdown.replace(/