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, 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

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.8.0.zip (15.1 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.8.0-py2.py3-none-any.whl (8.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ansiwrap-0.8.0.zip.

File metadata

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

File hashes

Hashes for ansiwrap-0.8.0.zip
Algorithm Hash digest
SHA256 d9be136416e14f5ee0ad81dbf7fb6c1ea5e3391e3350577e8b126649ff3fd6a3
MD5 8543c6c6744a164e788a90cde7a9c2ab
BLAKE2b-256 3630644a9088919982e4b20b57a8e1fd3e1ee1be115b3c913bda08f68a896007

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ansiwrap-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 80072b4129db581431fce17189d0c91a41f2fd543e58b31a9b46959423747554
MD5 c4916d2d16515397014c19bceca15104
BLAKE2b-256 a1b89157a91e67ecaf773557296ad880f75423425a5015b1341565188972a8c4

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 Pingdom Monitoring Sentry Error logging StatusPage Status page