[BUG] Text.from_ansi leaves empty lines when input string has CRLF line endings
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
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
- I've checked docs and closed issues for possible solutions.
- I can't find my issue in the FAQ.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Textualize/rich
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Textualize/rich#4223 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Textualize/rich#4222 ·
-
Needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Textualize/rich#4215 · 2 comments ·
-
Needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Textualize/rich#4214 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Textualize/rich#4213 · 2 comments · 1 reaction ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100