Skip to content

Fix doubled newlines in ANSI-escaped stream output - #14958

Merged
cderv merged 1 commit into
mainfrom
duplicated-newlines-in-ansi-escaped-output
Sep 28, 2026
Merged

cderv merged 1 commit into
mainfrom
duplicated-newlines-in-ansi-escaped-output

Conversation

@cderv

@cderv cderv commented Sep 28, 2026

Copy link
Copy Markdown
Member

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

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
@posit-snyk-bot

posit-snyk-bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv merged commit b3da648 into main Sep 28, 2026
51 checks passed
@cderv
cderv deleted the duplicated-newlines-in-ansi-escaped-output branch September 28, 2026 15:33
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.

Duplicated newlines in ansi-escaped-output

2 participants