mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
async function parseMarkdown(md) {
|
||||
const u = 'https://cdn.jsdelivr.net/npm/marked@9/lib/marked.esm.js';
|
||||
const o = {gfm:true,breaks:true,headerIds:false,mangle:false};
|
||||
|
||||
if (!md?.trim()) return '';
|
||||
try {
|
||||
const {marked} = await import(u);
|
||||
marked.setOptions(o);
|
||||
return marked.parse(md);
|
||||
} catch(e) {
|
||||
return `<p>${e.message}</p>`;
|
||||
const [{ marked }, { default: DOMPurify }] = await Promise.all([
|
||||
import('https://esm.sh/marked@9'),
|
||||
import('https://esm.sh/dompurify@3')
|
||||
]);
|
||||
marked.setOptions({ gfm: true, breaks: true });
|
||||
return DOMPurify.sanitize(marked.parse(md));
|
||||
} catch (e) {
|
||||
console.error('Markdown parse error:', e);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
export default parseMarkdown;
|
||||
Reference in New Issue
Block a user