Skip to content

Commit 501a37a

Browse files
committed
don't render before/after whitespace in interactive examples
1 parent 469d10f commit 501a37a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

js/interactive-examples.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ async function main() {
9494

9595
const runPhp = await PHP.loadPhp();
9696
runPhp(phpcode.innerText);
97+
const output = PHP.buffer.join("").replace(/^\n+|\n+$/g, "");
98+
9799
if (exampleScreenPreElement !== null) {
98100
exampleTitleParagraphElement.innerText = generateExampleOutputTitle(PHP.version);
99-
exampleScreenPreElement.innerText = PHP.buffer.join("");
101+
exampleScreenPreElement.innerText = output;
100102
} else {
101-
lastOutput = createOutput(PHP.buffer.join(""));
103+
lastOutput = createOutput(output);
102104
phpcode.parentNode.appendChild(lastOutput);
103105
}
104106
PHP.buffer.length = 0;

0 commit comments

Comments
 (0)