Skip to content

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

@kaipons

Description

@kaipons

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions