Files
yacy_search_server/htroot/js/index.umd.min.js
2025-11-23 23:56:26 +01:00

2 lines
1.6 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).markedHighlight={})}(this,function(e){"use strict";function r(e){return(e||"").match(/\S*/)[0]}function n(t){return e=>{"string"==typeof e&&e!==t.text&&(t.escaped=!0,t.text=e)}}const i=/[&<>"']/,o=new RegExp(i.source,"g"),s=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,g=new RegExp(s.source,"g"),t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=e=>t[e];function f(e,t){if(t){if(i.test(e))return e.replace(o,a)}else if(s.test(e))return e.replace(g,a);return e}e.markedHighlight=function(i){if((i="function"==typeof i?{highlight:i}:i)&&"function"==typeof i.highlight)return"string"!=typeof i.langPrefix&&(i.langPrefix="language-"),"string"!=typeof i.emptyLangClass&&(i.emptyLangClass=""),{async:!!i.async,walkTokens(e){if("code"===e.type){var t=r(e.lang);if(i.async)return Promise.resolve(i.highlight(e.text,t,e.lang||"")).then(n(e));t=i.highlight(e.text,t,e.lang||"");if(t 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.");n(e)(t)}},useNewRenderer:!0,renderer:{code(e,t,n){"object"==typeof e&&(n=e.escaped,t=e.lang,e=e.text);t=r(t),t=t?i.langPrefix+f(t):i.emptyLangClass,t=t?` class="${t}"`:"";return e=e.replace(/\n$/,""),`<pre><code${t}>${n?e:f(e,!0)}
</code></pre>`}}};throw new Error("Must provide highlight function")}});