Skip to content

Don't strip newlines when ANSI text is sent to print() - #73

Open
Qalthos wants to merge 3 commits into
pycontribs:mainfrom
Qalthos:print-multiline
Open

Qalthos wants to merge 3 commits into
pycontribs:mainfrom
Qalthos:print-multiline

Conversation

@Qalthos

@Qalthos Qalthos commented Jul 24, 2025

Copy link
Copy Markdown

AnsiDecoder.decode() takes a single str and returns a sequence of Text split by newline. If this is used directly, newlines in the source will not be restored when sent to print().

Using Lines instead of list lets us indicate to Rich that these Text objects should be interspersed with newlines.

Ref https://github.com/Textualize/rich/blob/master/rich/ansi.py#L126

AnsiDecoder.decode() takes a single str and returns a list of Text split
by newline. If this is used directly, newlines in the source will not be
restored when sent to print().

Using Lines instead of list lets us indicate to Rich that these Text
objects should be interspersed with newlines.

Ref https://github.com/Textualize/rich/blob/master/rich/ansi.py#L126
@github-actions

Copy link
Copy Markdown

Label error. Requires exactly 1 of: bug, chore, enhancement, major, minor, patch, skip-changelog. Found:

@Qalthos
Qalthos marked this pull request as draft July 24, 2025 17:39
@Qalthos
Qalthos marked this pull request as ready for review July 24, 2025 17:55
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.

1 participant