Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created January 24, 2024 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/e7a1d637755b93f73fe2d999ba446d5a to your computer and use it in GitHub Desktop.
Save JeffersGlass/e7a1d637755b93f73fe2d999ba446d5a to your computer and use it in GitHub Desktop.
Spurious HTML output when py-editors appear multiple time
<html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>PyScript Test</title>
<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
<script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
<!-- Code injected by live-server -->
<script>
// <![CDATA[ <-- For SVG support
if ('WebSocket' in window) {
(function () {
function refreshCSS() {
var sheets = [].slice.call(document.getElementsByTagName("link"));
var head = document.getElementsByTagName("head")[0];
for (var i = 0; i < sheets.length; ++i) {
var elem = sheets[i];
var parent = elem.parentElement || head;
parent.removeChild(elem);
var rel = elem.rel;
if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
}
parent.appendChild(elem);
}
}
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
var address = protocol + window.location.host + window.location.pathname + '/ws';
var socket = new WebSocket(address);
socket.onmessage = function (msg) {
if (msg.data == 'reload') window.location.reload();
else if (msg.data == 'refreshcss') refreshCSS();
};
if (sessionStorage && !sessionStorage.getItem('IsThisFirstTime_Log_From_LiveServer')) {
console.log('Live reload enabled.');
sessionStorage.setItem('IsThisFirstTime_Log_From_LiveServer', true);
}
})();
}
else {
console.error('Upgrade your browser. This Browser is NOT supported WebSocket for Live-Reloading.');
}
// ]]>
</script>
</head>
<body>
<script type="py-editor-active">
0
</script><py-editor id="py-editor-3" exec-id="0" root="py-editor-3" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-5-output"></div></div></py-editor>
<script type="py-editor-active-active">
1
</script><py-editor id="py-editor-9" exec-id="0" root="py-editor-9" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-11-output"></div></div></py-editor><py-editor id="py-editor-0" exec-id="0" root="py-editor-0" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-2-output"></div></div></py-editor>
<script type="py-editor-active-active">
2
</script><py-editor id="py-editor-15" exec-id="0" root="py-editor-15" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-17-output"></div></div></py-editor><py-editor id="py-editor-6" exec-id="0" root="py-editor-6" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-8-output"></div></div></py-editor>
<script type="py-editor-active-active">
3
</script><py-editor id="py-editor-21" exec-id="0" root="py-editor-21" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-23-output"></div></div></py-editor><py-editor id="py-editor-12" exec-id="0" root="py-editor-12" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-14-output"></div></div></py-editor>
<script type="py-editor-active-active">
4
</script><py-editor id="py-editor-27" exec-id="0" root="py-editor-27" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-29-output"></div></div></py-editor><py-editor id="py-editor-18" exec-id="0" root="py-editor-18" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-20-output"></div></div></py-editor>
<script type="py-editor-active-active">
5
</script><py-editor id="py-editor-30" exec-id="0" root="py-editor-30" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-32-output"></div></div></py-editor><py-editor id="py-editor-24" exec-id="0" root="py-editor-24" style="display: block;"><div class="py-editor-box" data-env="pyodide"><div class="py-editor-input" aria-label="Python Script Area"><button class="absolute py-editor-run-button" aria-label="Python Script Run Button"><svg style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg></button><div></div></div><div class="py-editor-output" id="py-editor-26-output"></div></div></py-editor>
<!-- more... -->
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment