Skip to main content
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, but 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

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.5.4.zip (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansiwrap-0.5.4-py2.py3-none-any.whl (7.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ansiwrap-0.5.4.zip.

File metadata

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

File hashes

Hashes for ansiwrap-0.5.4.zip
Algorithm Hash digest
SHA256 e2b4e79f57e059b4fee48a598aacb9c072cfa22a251a4d7b119183b4c92eb93c
MD5 683135eff7f5b053bfe7edb84d70097d
BLAKE2b-256 47fd8342429b86169d732fc311ac57bbbbd4ef7306891df2c78bcb9ca7b7b00c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ansiwrap-0.5.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 01d4a7dcd296e119cf0ca3f5bafc8786e14bdbcde09c7850462efa0a838a19c8
MD5 8fc2eb071a36dc0ed40be863edd5ef12
BLAKE2b-256 4316040b5cb3b4a01721626bedff5a7b05b7850adf7f2ea3ab0832cbc4abe92d

See more details on using hashes here.

Supported by

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