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,7 @@
|
||||
async function parseMarkdown(t) {
|
||||
const { marked } = await import("https://esm.sh/marked@12.0.0");
|
||||
return marked.parse(t);
|
||||
async function parseMarkdown(md) {
|
||||
const { marked } = await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js');
|
||||
return marked.parse(md);
|
||||
}
|
||||
export default parseMarkdown;
|
||||
export default parseMarkdown;
|
||||
// Generation time: 2.905s
|
||||
// Result: PASS
|
||||
@@ -2,4 +2,6 @@ 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;
|
||||
export default parseMarkdown;
|
||||
// Generation time: 1.766s
|
||||
// Result: PASS
|
||||
@@ -1,24 +0,0 @@
|
||||
const parseMarkdown = async (md) => {
|
||||
try {
|
||||
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);
|
||||
const el = document.createElement('div');
|
||||
el.textContent = md || '';
|
||||
return el.innerHTML;
|
||||
}
|
||||
};
|
||||
export default parseMarkdown;
|
||||
@@ -1,5 +1,7 @@
|
||||
const parseMarkdown = async text => {
|
||||
const { parse } = await import('https://esm.sh/marked')
|
||||
return parse(text)
|
||||
const parseMarkdown = async (md) => {
|
||||
const { parse } = await import('https://esm.sh/marked@12.0.0')
|
||||
return parse(String(md || ''))
|
||||
}
|
||||
export default parseMarkdown;
|
||||
export default parseMarkdown;
|
||||
// Generation time: 42.618s
|
||||
// Result: PASS
|
||||
@@ -1,15 +1,13 @@
|
||||
async function parseMarkdown(md) {
|
||||
if (!md?.trim()) return '';
|
||||
try {
|
||||
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;
|
||||
let p;
|
||||
|
||||
export const parseMarkdown = async (s) => {
|
||||
p ||= Promise.all([
|
||||
import('https://esm.sh/marked@7.0.4').then(r => r.marked),
|
||||
import('https://esm.sh/dompurify@3.0.5').then(r => r.default)
|
||||
]);
|
||||
const [m, d] = await p;
|
||||
return d.sanitize(m.parse(s));
|
||||
};
|
||||
export default parseMarkdown;
|
||||
// Generation time: 550.549s
|
||||
// Result: PASS
|
||||
@@ -1,12 +1,17 @@
|
||||
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;
|
||||
const loadLibs=(()=>{let cache;return async()=>cache||(cache=Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/marked@11.1.0/lib/marked.esm.js'),
|
||||
import('https://cdn.jsdelivr.net/npm/dompurify@3.0.6/dist/purify.es.mjs')
|
||||
]).then(([{marked},purifyMod])=>{
|
||||
const purify=(purifyMod.default||purifyMod)(window);
|
||||
marked.setOptions({gfm:true,headerIds:true,mangle:false});
|
||||
return {marked,purify};
|
||||
}));})();
|
||||
|
||||
const parseMarkdown=async input=>{
|
||||
const {marked,purify}=await loadLibs();
|
||||
const html=marked.parse(typeof input==='string'?input:`${input??''}`);
|
||||
return purify.sanitize(html,{USE_PROFILES:{html:true}});
|
||||
};
|
||||
export default parseMarkdown;
|
||||
// Generation time: 15.618s
|
||||
// Result: FAIL
|
||||
@@ -1,15 +0,0 @@
|
||||
const parseMarkdown = async (markdown) => {
|
||||
const { default: marked } = await import('https://cdn.jsdelivr.net/npm/marked@4.0.12/lib/marked.esm.js')
|
||||
const { default: DOMPurify } = await import('https://cdn.jsdelivr.net/npm/dompurify@3.0.5/dist/purify.es.mjs')
|
||||
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
breaks: true,
|
||||
headerIds: false,
|
||||
mangle: false
|
||||
})
|
||||
|
||||
const html = marked.parse(markdown)
|
||||
return DOMPurify.sanitize(html)
|
||||
}
|
||||
export default parseMarkdown;
|
||||
@@ -1,6 +0,0 @@
|
||||
async function parseMarkdown(md){
|
||||
const{marked}=await import('https://esm.sh/marked');
|
||||
const{DOMPurify}=await import('https://esm.sh/dompurify');
|
||||
return DOMPurify.sanitize(marked.parse(md));
|
||||
}
|
||||
export default parseMarkdown;
|
||||
@@ -1,5 +0,0 @@
|
||||
async function parseMarkdown(md) {
|
||||
const { marked } = await import('https://cdn.skypack.dev/marked');
|
||||
return marked.parse(md);
|
||||
}
|
||||
export default parseMarkdown;
|
||||
7
tests/5_markdown_parser/outputs/x-ai_grok-4.js
Normal file
7
tests/5_markdown_parser/outputs/x-ai_grok-4.js
Normal file
@@ -0,0 +1,7 @@
|
||||
async function parseMarkdown(markdown) {
|
||||
const { marked } = await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js');
|
||||
return marked(markdown);
|
||||
}
|
||||
export default parseMarkdown;
|
||||
// Generation time: 16.386s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user