/* Markdown Bundle for Nebot Page */ (function(){ try { // Try to load libraries if available in Node context if (typeof require !== 'undefined') { const marked = require('marked'); const createDOMPurify = require('dompurify'); const { JSDOM } = require('jsdom'); // Create a DOM window for DOMPurify if needed let DOMPurify; if (typeof window !== 'undefined') { DOMPurify = createDOMPurify(window); } else { const window = new JSDOM('').window; DOMPurify = createDOMPurify(window); } // Configure marked marked.setOptions({ breaks: true, highlight: function(code, lang) { if (window.hljs && lang && window.hljs.getLanguage(lang)) { try { return window.hljs.highlight(code, { language: lang }).value; } catch (e) {} } return code; } }); // Expose to global scope window.marked = marked; window.DOMPurify = DOMPurify; } else { console.warn('[Markdown Bundle] require() not available, libraries may not be loaded'); } } catch (e) { console.error('[Markdown Bundle] Error loading libraries:', e); // Fallback: simple markdown-like parsing window.marked = { parse: function(md) { if (!md) return ''; // Basic markdown parsing return md .replace(/\*\*(.*?)\*\*/g, '$1') .replace(/\*(.*?)\*/g, '$1') .replace(/`([^`]+)`/g, '$1') .replace(/^# (.*$)/gim, '

$1

') .replace(/^## (.*$)/gim, '

$1

') .replace(/^### (.*$)/gim, '

$1

') .replace(/\n/g, '
'); } }; window.DOMPurify = { sanitize: function(html) { // Basic sanitization - strip script tags return html.replace(/)<[^<]*)*<\/script>/gi, ''); } }; } })();