💡 Ask Tutor
Code Compiler
Output
\n`; editor.setValue(sampleHtml);function runCode() { updateOutput(); }function clearCode() { editor.setValue(''); updateOutput(); }function toggleTheme() { const isDark = document.body.classList.toggle('light-theme'); editor.setOption('theme', isDark ? 'default' : 'dracula'); document.getElementById('theme-toggle').innerHTML = ` ${isDark ? 'Light' : 'Dark'}`; updateOutput(); }function updateOutput() { const code = editor.getValue(); const outputFrame = document.getElementById('output'); const isLightTheme = document.body.classList.contains('light-theme'); try { const doc = outputFrame.contentDocument || outputFrame.contentWindow.document; doc.open(); doc.write(`${code} `); doc.close(); } catch (e) { console.error('Error rendering HTML:', e); } }editor.on('change', updateOutput); updateOutput();