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

Uploaded Python 2Python 3

File details

Details for the file ansiwrap-0.6.0.zip.

File metadata

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

File hashes

Hashes for ansiwrap-0.6.0.zip
Algorithm Hash digest
SHA256 ad7f091defca2f043f9e8a52feaaf838d96515ab23441490d0ad032a5fb5eca8
MD5 fc2077d8f3dc6a369fc656c2d2e065a0
BLAKE2b-256 f455289b4b64b0e1302b55b126d22fd23e5287703d0c42a618e97790c38331b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ansiwrap-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5603a96e18dd5dc487e0c5029e7bd7b34a6547884e65fe0cad2c6840d490b8a3
MD5 44de2c6e72a37f8620239348a5c29f12
BLAKE2b-256 ac0a67c694ac200b3939ba4dd58cf5ef7dd793e4d4e5b04e04f3bb5e5ff51f39

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