Skip to content

Commit 8f5ee4c

Browse files
authored
fix: set pyodide's output via Node.textContent
Signed-off-by: Timothée Mazzucotelli <dev@pawamoy.fr>
1 parent c7398c4 commit 8f5ee4c

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

  • src/assets/javascripts/components/content/exec

src/assets/javascripts/components/content/exec/index.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* IN THE SOFTWARE.
2424
*/
2525

26-
import escapeHtml from "escape-html";
27-
2826
import {
2927
Observable,
3028
catchError,
@@ -200,7 +198,7 @@ function getSession(name: string, pyodide: PyodideInterface): unknown {
200198
* @param string - Output
201199
*/
202200
function writeOutput(element: HTMLElement, string: string): void {
203-
element.innerHTML = escapeHtml(string);
201+
element.textContent = string;
204202
}
205203

206204
/**
@@ -209,18 +207,7 @@ function writeOutput(element: HTMLElement, string: string): void {
209207
* @param element - Output element
210208
*/
211209
function clearOutput(element: HTMLElement): void {
212-
element.innerHTML = "";
213-
}
214-
215-
/**
216-
* Escape output like the original script
217-
*
218-
* @param string - Raw output
219-
*
220-
* @returns Escaped output
221-
*/
222-
function escapeOutput(string: string): string {
223-
return new Option(string).innerHTML;
210+
element.textContent = "";
224211
}
225212

226213
/**
@@ -264,7 +251,7 @@ async function evaluatePython(
264251
writeOutput(output, `${lines.join("\n")}\n`);
265252
}
266253
} catch (error) {
267-
lines.push(escapeOutput(String(error)));
254+
lines.push(String(error));
268255
writeOutput(output, `${lines.join("\n")}\n`);
269256
}
270257
}

0 commit comments

Comments
 (0)