junkembed.html
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/python.min.js"></script>
<style>
.junkpre { border: 1px solid black; max-width: 132ex; max-height: 45lh; overflow: auto; }
</style>
<script>
const do_embed = function(container, url) {
const request = new Request(url);
fetch(request)
.then((response) => response.json())
.then((data) => {
container.textContent = atob(data['content']);
hljs.highlightElement(container)
})
.catch((error) => {
console.error(error);
});
}
const do_embed_here = function(url, classes) {
const id = "embed" + (((1 + Math.random()) * 0x1000000) | 0).toString(16).substring(1);
document.write("<pre class=junkpre><code id=" + id + " class=junkembed></code></pre>")
const el = document.getElementById(id)
if (classes) {
el.className = el.className + " " + classes
}
do_embed(el, url)
}
</script>
</head>
<body>
I'm a simple HTML page.
<script>
do_embed_here("https://codeberg.org/api/v1/repos/jepler/junkdrawer/contents/aygdu2e9/junk.py?ref=main", "language-python");
</script>
</body>
</html>