Skip to content

bubble-tea-project/ansiparser

Repository files navigation

AnsiParser

A convenient library for converting ANSI escape sequences into text or HTML.

PyPI - Stable Version PyPI - Python Version GitHub Actions Workflow Status GitHub License

📖 Description

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.

✨ Supported Features

  • CSI (Control Sequence Introducer) sequences
    • SGR (Select Graphic Rendition)
    • CUP (Cursor Position)
    • ED (Erase in Display)
    • EL (Erase in Line)
  • Convert
    • formatted text
    • HTML

📦 Installation

AnsiParser is available on PyPI:

python -m pip install ansiparser

Or you can use Poetry:

poetry add ansiparser

🎨 Usage

import 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!']

🔗 Links

📜 License

GitHub License

About

A convenient library for converting ANSI escape sequences into text or HTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published