added innerhtml linebreaks after every print to console
parent
ffb5050b13
commit
4904e2901c
|
|
@ -44,7 +44,8 @@
|
||||||
class ConsoleOutput:
|
class ConsoleOutput:
|
||||||
def write(self, text):
|
def write(self, text):
|
||||||
console = document.getElementById("console")
|
console = document.getElementById("console")
|
||||||
console.textContent += text
|
|
||||||
|
console.innerHTML += text.replace("\\n", "<br>") # Convert newlines to <br>
|
||||||
console.scrollTop = console.scrollHeight # Auto-scroll to bottom
|
console.scrollTop = console.scrollHeight # Auto-scroll to bottom
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
|
|
@ -54,6 +55,7 @@
|
||||||
sys.stderr = ConsoleOutput()
|
sys.stderr = ConsoleOutput()
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
|
||||||
return pyodide;
|
return pyodide;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,8 +82,7 @@
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example usage
|
|
||||||
const input = " Line 1\n Line 2\nLine 3";
|
|
||||||
const output = addExtraLineWithIndent(code, "await asyncio.sleep(0.01)");
|
const output = addExtraLineWithIndent(code, "await asyncio.sleep(0.01)");
|
||||||
console.log(output);
|
console.log(output);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue