1/** 2 * Configuration for marked.js to prevent 't is not defined' error in Chromium browsers 3 * This file initializes marked.js with the proper options to prevent blob URL errors 4 */ 5(function() { 6 // Debug flag - set to false to disable console logging 7 const DEBUG = false; 8 9 if (DEBUG) { 10 // marked-config.js loaded 11 } 12 13 // Store initialization state 14 window.aixgMarkedConfigured = window.aixgMarkedConfigured || false; 15 16 // Wait for document to be ready 17 function initMarkedConfig() { 18 if (window.aixgMarkedConfigured) { 19 if (DEBUG) { 20 // Marked already configured, skipping 21 } 22 return; 23 } 24 25 if (typeof marked !== 'undefined') { 26 if (DEBUG) { 27 // Configuring marked.js 28 } 29 30 try { 31 // Configure marked.js with options to prevent errors 32 marked.use({ 33 mangle: false, 34 headerIds: false, 35 langPrefix: '' 36 }); 37 38 // Add defensive error handling for blob URLs 39 const originalParse = marked.parse; 40 marked.parse = function(src, opt, callback) { 41 try { 42 // Handle null/undefined input 43 if (!src) { 44 if (DEBUG) console.warn('AIXG: Empty source passed to marked.parse'); 45 return ''; 46 } 47 48 return originalParse.call(this, src, opt, callback); 49 } catch (error) { 50 if (DEBUG) console.warn('AIXG: Marked.js error caught and handled:', error.message); 51 // Return sanitized content as fallback 52 return String(src) 53 .replace(/&/g, '&') 54 .replace(/</g, '<') 55 .replace(/>/g, '>') 56 .replace(/"/g, '"') 57 .replace(/'/g, ''') 58 .replace(/\n/g, '<br>'); 59 } 60 }; 61 62 // Set flag that marked has been configured 63 window.aixgMarkedConfigured = true; 64 65 if (DEBUG) { 66 // Marked.js configuration applied successfully 67 } 68 } catch (configError) { 69 if (DEBUG) { 70 // Failed to configure marked.js 71 } 72 } 73 } else { 74 if (DEBUG) { 75 // Marked.js not found 76 } 77 78 // Try again in 500ms - in case marked.js loads after this script 79 setTimeout(initMarkedConfig, 500); 80 } 81 } 82 83 // Try to initialize as soon as DOM is ready 84 if (document.readyState === 'loading') { 85 document.addEventListener('DOMContentLoaded', function() { 86 if (DEBUG) { 87 // DOMContentLoaded event fired 88 } 89 initMarkedConfig(); 90 }); 91 } else { 92 // DOM already loaded, run immediately 93 setTimeout(function() { 94 if (DEBUG) { 95 // setTimeout callback fired 96 } 97 initMarkedConfig(); 98 }, 0); 99 } 100 101 // Also try on window load as a fallback 102 window.addEventListener('load', function() { 103 if (DEBUG) {
104 // Window load event fired 105 } 106 initMarkedConfig(); 107 }); 108})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.