Skip to main content

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

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansiparser-1.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

ansiparser-1.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file ansiparser-1.1.0.tar.gz.

File metadata

  • Download URL: ansiparser-1.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ansiparser-1.1.0.tar.gz
Algorithm Hash digest
SHA256 258845f41d9036f839454a952482cca0254efb3d6b4b6f1d5257ede0e32ae605
MD5 c639a8e4be99ee9965ad7aa841e2baae
BLAKE2b-256 de64d2277b0613251d7fc79c6167e46fde01775f6a3da39bd08bd6c4dcd08fce

See more details on using hashes here.

File details

Details for the file ansiparser-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ansiparser-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ansiparser-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db89e72a5cb5e202ae4b9068be1354225e782dc339ce39426511bf6f5b5bea19
MD5 e565798c7115e85777f0a4bce9c2569b
BLAKE2b-256 c0d133f65d1bd979f5070b51c01e4b3a1f2b9b28bbb960dd6d514212d11c4980

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page