r-wasm / quarto-live

WebAssembly powered code blocks and exercises for both the R and Python languages in Quarto documents
https://r-wasm.github.io/quarto-live/
MIT License
128 stars 9 forks source link

Cell output should escape text #69

Open kcarnold opened 1 month ago

kcarnold commented 1 month ago

I noticed that trying to print(type(10)) doesn't show anything.

This is probably because stdout isn't getting escaped: https://github.com/r-wasm/quarto-live/blob/926fb881a787a80c8a2a4d8bb9250166d21d7a76/live-runtime/src/evaluate-pyodide.ts#L332

The solution could look like:

      const outputDiv = document.createElement("div");
      outputDiv.className = "exercise-cell-output cell-output cell-output-pyodide cell-output-stdout";
      outputDiv.innerHTML = `<pre><code></code></pre>`;
      outputDiv.querySelector('code').textContent = result.stdout;
      container.appendChild(outputDiv);

The same should apply to stderr.