From 501a37a2d628fa45fde73c8d7ddb36c98bfa2662 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Fri, 8 May 2026 19:17:36 +0200 Subject: [PATCH] don't render before/after whitespace in interactive examples --- js/interactive-examples.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/interactive-examples.js b/js/interactive-examples.js index 7f2d41e90c..eb296c94df 100644 --- a/js/interactive-examples.js +++ b/js/interactive-examples.js @@ -94,11 +94,13 @@ async function main() { const runPhp = await PHP.loadPhp(); runPhp(phpcode.innerText); + const output = PHP.buffer.join("").replace(/^\n+|\n+$/g, ""); + if (exampleScreenPreElement !== null) { exampleTitleParagraphElement.innerText = generateExampleOutputTitle(PHP.version); - exampleScreenPreElement.innerText = PHP.buffer.join(""); + exampleScreenPreElement.innerText = output; } else { - lastOutput = createOutput(PHP.buffer.join("")); + lastOutput = createOutput(output); phpcode.parentNode.appendChild(lastOutput); } PHP.buffer.length = 0;