Skip to main content

A Python library that makes formatting, colouring and adding emojis to terminal printouts easy.

Project description

Fansi

Fansi is a Python library that makes formatting, colouring and adding emojis to terminal printouts easy.

fansi demo

Installation

pip install fansi

To uninstall: pip uninstall fansi

Usage

First steps

First, include fansi in your script:

from fansi import fansi

Then, instead of print() statements, use fansi.say()

fansi.say("This string can have fansi formatting!")

Basic formatting

To add italics, use _tags_ or *tags*. To add bolding, use __tags__ or **tags**. To add bolding and italics, use ___tags___ or ***tags***.

For example:

fansi.say("This _text will be italicised_. This text will be **bolded**. ___This text will be both___.")

Inline tagging

You can add Ansi formatting characters inline, affecting the colour or emphasis of your text, using ::tags:: To reset the formatting, use the ::end:: tag.

For example:

fansi.say("This text will be normal. ::green bold italics:: This text will be green, bold and italicised. ::end:: This text will be back to normal.")

Global tags

Fansi tags can also be added to the entire string.

For example: fansi.say("This text will be magenta on a blue background.", "magenta bg-blue")

Emojis

You can also add any emoji, using :tags:. Long and shortnames work.

For example:

fansi.say("Here are some :poop: emojis! :panda_face::tiger::cat:")'

That's it!

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

fansi-0.1.2.tar.gz (38.9 kB view hashes)

Uploaded Source

Built Distribution

fansi-0.1.2-py3-none-any.whl (267.4 kB view hashes)

Uploaded Python 3

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