[BUG] Text.from_ansi leaves empty lines when input string has CRLF line endings

Open Beginner friendly
#4,090 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start at the Text.from_ansi entry point and reproduce the reported behavior with the CRLF string shown in the issue. Confirm that the resulting plain text preserves the expected content and line endings rather than producing empty lines.

Written by the indexing model from the issue text.

Description

Needs triage

Describe the bug

When Text.from_ansi is given an input string with CRLF (\r\n) line endings the result is just empty lines:

Python 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] on linux                                                                                                                                                                                             
Type "help", "copyright", "credits" or "license" for more information.                                                                                                                                                                                        
>>> from rich.text import Text
>>> Text.from_ansi("Hello\r\nWorld\r\n").plain                  
'\n\n'

when the expected result would be

'Hello\r\nWorld\r\n'

or even

'Hello\nWorld\n'

rich versions <15.0.0 are affected by #3577 but do not result in empty lines.

Platform

  • python 3.12.3
  • rich 15.0.0
Dominant language
Python
Stars
57.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Textualize/rich

All issues in Textualize/rich

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.