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,5 +1,5 @@
|
||||
const parseMarkdown = async (md) => {
|
||||
const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11/+esm');
|
||||
async function parseMarkdown(md) {
|
||||
const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11.1.1/+esm');
|
||||
return marked.parse(md);
|
||||
};
|
||||
}
|
||||
export default parseMarkdown;
|
||||
@@ -1,12 +1,24 @@
|
||||
const parseMarkdown = async (markdownText) => {
|
||||
const cdnUrl = 'https://cdn.jsdelivr.net/npm/marked@13.0.2/lib/marked.esm.js';
|
||||
|
||||
const parseMarkdown = async (md) => {
|
||||
try {
|
||||
const { marked } = await import(cdnUrl);
|
||||
return marked.parse(markdownText || '');
|
||||
const [
|
||||
{ marked },
|
||||
{ default: DOMPurify }
|
||||
] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/marked@13.0.0/lib/marked.esm.js'),
|
||||
import('https://cdn.jsdelivr.net/npm/dompurify@3.1.5/dist/purify.es.mjs')
|
||||
]);
|
||||
|
||||
const rawHtml = marked.parse(md || '', {
|
||||
gfm: true,
|
||||
breaks: true,
|
||||
});
|
||||
|
||||
return DOMPurify.sanitize(rawHtml);
|
||||
} catch (err) {
|
||||
console.error(`Failed to parse markdown: ${err}`);
|
||||
return markdownText || '';
|
||||
console.error('Failed to parse markdown:', err);
|
||||
const el = document.createElement('div');
|
||||
el.textContent = md || '';
|
||||
return el.innerHTML;
|
||||
}
|
||||
};
|
||||
export default parseMarkdown;
|
||||
@@ -0,0 +1,5 @@
|
||||
const parseMarkdown = async text => {
|
||||
const { parse } = await import('https://esm.sh/marked')
|
||||
return parse(text)
|
||||
}
|
||||
export default parseMarkdown;
|
||||
@@ -1,5 +0,0 @@
|
||||
const parseMarkdown = async md => {
|
||||
const { parse } = await import('https://cdn.jsdelivr.net/npm/marked@12.0.1/lib/marked.esm.js')
|
||||
return parse(md)
|
||||
}
|
||||
export default parseMarkdown;
|
||||
@@ -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;
|
||||
@@ -1,5 +1,12 @@
|
||||
const parseMarkdown=async m=>{
|
||||
const {marked}=await import('https://cdn.jsdelivr.net/npm/marked@11.1.0/lib/marked.esm.js')
|
||||
return marked.parse(m)
|
||||
}
|
||||
const parseMarkdown=(()=>{
|
||||
let m,r
|
||||
return async t=>{
|
||||
if(!r){
|
||||
({marked:m}=await import('https://cdn.jsdelivr.net/npm/marked@11.1.1/+esm'))
|
||||
m.setOptions({gfm:1,mangle:0,headerIds:0})
|
||||
r=1
|
||||
}
|
||||
return m.parse(t)
|
||||
}
|
||||
})()
|
||||
export default parseMarkdown;
|
||||
@@ -1,5 +1,6 @@
|
||||
async function parseMarkdown(md){
|
||||
const{marked}=await import('https://esm.sh/marked');
|
||||
return marked.parse(md);
|
||||
const{DOMPurify}=await import('https://esm.sh/dompurify');
|
||||
return DOMPurify.sanitize(marked.parse(md));
|
||||
}
|
||||
export default parseMarkdown;
|
||||
Reference in New Issue
Block a user