17 lines
530 B
JavaScript
17 lines
530 B
JavaScript
// Shared markdown → sanitized HTML helper.
|
|
// Used by the companion chat rail and any other component that needs
|
|
// safe rendered markdown outside the full editor.
|
|
|
|
import { marked } from './vendor/marked.esm.js';
|
|
import DOMPurify from './vendor/purify.es.mjs';
|
|
|
|
marked.setOptions({ gfm: true, breaks: true });
|
|
|
|
/**
|
|
* Parse `src` as Markdown and return a DOMPurify-sanitized HTML string.
|
|
* Safe to assign to element.innerHTML.
|
|
*/
|
|
export function renderMarkdown(src) {
|
|
return DOMPurify.sanitize(marked.parse(src || ''));
|
|
}
|