import { markdownToHtml } from "./markdown"; import { escapeHtml, sanitizeTemplateData } from "./security"; import { templates } from "./templates"; import type { GenerateOptions } from "./types"; export function generateHtml(options: GenerateOptions): string { let bodyContent = ""; if (options.template && options.data) { const templateFn = templates[options.template]; if (templateFn) { const sanitizedData = sanitizeTemplateData(options.data); return templateFn(sanitizedData); } } if (options.content) { switch (options.contentType) { case "markdown": bodyContent = markdownToHtml(options.content); break; case "html": bodyContent = options.content; break; case "text": bodyContent = `
${escapeHtml(options.content)}`;
break;
}
}
return `