Skip to content

Conversation

@OnkarRuikar
Copy link
Contributor

@OnkarRuikar OnkarRuikar commented Aug 31, 2025

Description

The output lines are displayed only in <code> blocks, so the HTML rendering is collapsing the whitespaces. As the content is only the text log strings, using only inline <pre> blocks solves the problem.

Additional details

Code used to test:

const greeting = "   ad   a       bd  a   ";
console.log(greeting);
console.log(greeting);

Before fix

1

4

After fix

5

6

Related issues and pull requests

Fixes #668

@OnkarRuikar OnkarRuikar requested a review from a team as a code owner August 31, 2025 09:42
@caugner caugner changed the title fix(playconsole): avoid whitespace collapse in logs fix(play-console): preserve whitespace Sep 1, 2025
@OnkarRuikar OnkarRuikar requested a review from caugner September 2, 2025 06:51
}

code {
pre {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change causes long lines to no longer break:

Where Screenshot
Local image
Prod image

Maybe we should use neither code nor pre, and just set white-space: preserve?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just white-space: preserve isn't cutting it. The > and ####... are getting rendered on different lines.
We need <li> to not wrap and the text content to wrap. Let me know how the latest commit fares:

1

Code used

console.log("   abcd  d   c  ");
console.log("   abcd  \nd   c  ");
console.log("a".repeat(300));

Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a fixed width for the line indicator, and reuse that width for calculating the code with.

@OnkarRuikar OnkarRuikar requested a review from caugner September 15, 2025 04:35
@caugner caugner requested a review from a team as a code owner October 23, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interactive example collapses whitespace in output

2 participants