Shiki demo

by ckissi

HTML

<div id="foo">
</div>

<button onclick="newcode()">
    New code
</button>

 <button onclick="changeText()">Click Me!</button>

JavaScript

// be sure to specify the exact version
import { codeToHtml } from 'https://esm.run/[email protected]' 

const foo = document.getElementById('foo')
foo.innerHTML = await codeToHtml('console.log("Hi! Shiki on CDN :)")', { lang: 'js', theme: 'github-dark' })

window.newcode =  async function() {
  foo.innerHTML = await codeToHtml('console.log("Hi! Shiki on CDN 22:)")', { lang: 'js', theme: 'github-dark' });
}

function changeText() {
            document.getElementById("text").innerHTML = "The text has been changed!";
        }