Fix doubled newlines in ANSI-escaped stream output - #14958
Merged
Merged
Conversation
nbformat stores stream `text` as a list of lines that each keep their trailing newline, and fixupStreams concatenates consecutive writes to the same stream. The ANSI-to-HTML branch of mdOutputStream joined those lines with "\n", so every line break was doubled and separate writes (`print(..., end="")` then `print(...)`) got a newline inserted between them. The plain-text path already joins with "", as does JupyterLab. Tracebacks keep their "\n" join: their entries are not consistently newline terminated, and JupyterLab joins them the same way. Fixes #13966
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When rendering Jupyter notebook output containing ANSI escape codes to HTML, doubled newlines appear, showing blank lines between every output line.
Notebook stream output lines already include their trailing newlines. Joining them with an extra newline duplicates the line breaks. The fix joins them with an empty string instead, preserving the original line structure.
Fixes #13966