function o(e){if("function"==typeof e&&(e={highlight:e}),!e||"function"!=typeof e.highlight)throw new Error("Must provide highlight function");return"string"!=typeof e.langPrefix&&(e.langPrefix="language-"),"string"!=typeof e.emptyLangClass&&(e.emptyLangClass=""),{async:!!e.async,walkTokens(t){if("code"!==t.type)return;const n=s(t.lang);if(e.async)return Promise.resolve(e.highlight(t.text,n,t.lang||"")).then(g(t));const r=e.highlight(t.text,n,t.lang||"");if(r instanceof Promise)throw new Error("markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.");g(t)(r)},useNewRenderer:!0,renderer:{code(t,n,r){"object"==typeof t&&(r=t.escaped,n=t.lang,t=t.text);const i=s(n),o=i?e.langPrefix+l(i):e.emptyLangClass,g=o?` class="${o}"`:"";return t=t.replace(/\n$/,""),`<pre><code${g}>${r?t:l(t,!0)}\n</code></pre>`}}}}function s(e){return(e||"").match(/\S*/)[0]}function g(e){return t=>{"string"==typeof t&&t!==e.text&&(e.escaped=!0,e.text=t)}}const f=/[&<>"']/,p=new RegExp(f.source,"g"),u=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,y=new RegExp(u.source,"g"),x={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i=e=>x[e];function l(e,t){if(t){if(f.test(e))return e.replace(p,i)}else if(u.test(e))return e.replace(y,i);return e}export{o as m};