Parse ANSI escape sequences into screen outputs. This library implements a parser that processes escape sequences like a terminal, allowing you to convert them into formatted text or HTML.
- CSI (Control Sequence Introducer) sequences
- SGR (Select Graphic Rendition)
- CUP (Cursor Position)
- ED (Erase in Display)
- EL (Erase in Line)
- Convert
- formatted text
- HTML
AnsiParser is available on PyPI:
python -m pip install ansiparserOr you can use Poetry:
poetry add ansiparserimport ansiparser
ansip_screen = ansiparser.new_screen()
ansip_screen.put("\x1b[1;6H-World!\x1b[1;1HHello")
ansip_screen.parse()
converted = ansip_screen.to_formatted_string()
print(converted) # ['Hello-World!']