1// Transform ANSI sequence in Prism Block into color 2// https://github.com/drudru/ansi_up 3window.addEventListener('load', () => { 4 // It's a module wo we need to import it dynamically to use it in the browser (non-module) 5 import('https://cdn.jsdelivr.net/npm/ansi_up@6.0.6/ansi_up.min.js').then(m => { 6 AnsiUp = m.AnsiUp 7 const ansi_up = new AnsiUp(); 8 9 // Note sure how does the 10 // �: the replacement character () appears when Invalid UTF-8 sequences are encountered 11 const elements = document.querySelectorAll('code.language-txt') 12 for (const element of elements) { 13 const ansiText = element.textContent.replace(/�/g, '\x1B') 14 element.innerHTML = ansi_up.ansi_to_html(ansiText) 15 } 16 }) 17}) 18