Skip to main content

textwrap, but savvy to ANSI colors and styles

Project description

travisci PyPI Package latest release Supported versions Supported implementations Wheel packaging support Test line coverage

ansiwrap wraps text, like the standard textwrap module. But it also correctly wraps text that contains ANSI control sequences that colorize or style text.

Where textwrap is fooled by the raw string length of those control codes, ansiwrap is not; it understands that however much those codes affect color and display style, they have no logical length.

The API mirrors the wrap and fill functions of textwrap.

It also exports several other functions:

  • ansilen (giving the effective length of a string, ignoring ANSI control codes)

  • ansi_terminate_lines (propogates control codes though a list of strings/lines and terminates each line.)

  • strip_color (removes ANSI control codes from a string)

See also the enclosed demo.py.

https://content.screencast.com/users/jonathaneunice/folders/Jing/media/8db64be2-01cc-4da4-b46a-789c53c63b44/00000569.png

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

ansiwrap-0.7.1.zip (30.0 kB view details)

Uploaded Source

Built Distribution

ansiwrap-0.7.1-py2.py3-none-any.whl (14.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ansiwrap-0.7.1.zip.

File metadata

  • Download URL: ansiwrap-0.7.1.zip
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ansiwrap-0.7.1.zip
Algorithm Hash digest
SHA256 f3c18f7ed04e3a8a13981aca48d19a1f3b4251ae82d1ec106add502c04b38f0a
MD5 8287f3fe637711a14ffd6e2c2ba1e99a
BLAKE2b-256 601b401f93e9647ff67d9b31fba2be3c5a20a71138b6330c72727058574845d8

See more details on using hashes here.

File details

Details for the file ansiwrap-0.7.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ansiwrap-0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 692315ce31c7ad135af78b71a1178f63071ed310045982867a3e505712532d60
MD5 55222b37236a08d22962b5ba5f6670b9
BLAKE2b-256 739977ea4afe9927ecad1de5422994506378bce72262eedfcdd6e97749669401

See more details on using hashes here.

Supported by

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