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.
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!")
If you want to generate a formatted string without printing it, use fansi.format().
a = fansi.format("Here's a string ::blue:: formatted with Ansi characters! ::end:: It's partly blue!")
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!
Appendix: Fansi tags
| Tag | Description |
|---|---|
bold |
Bold text |
italics |
Italicised text |
underline |
Underlined text |
blink |
Blinking text (don't) |
invisible |
Invisible text |
| -------------- | ----------------------- |
black |
Black text |
red |
Red text |
green |
Green text |
yellow |
Yellow text |
blue |
Blue text |
magenta |
Magenta text |
cyan |
Cyan text |
white |
White text |
| -------------- | ----------------------- |
bg-black |
Black background |
bg-red |
Red background |
bg-green |
Green background |
bg-yellow |
Yellow background |
bg-blue |
Blue background |
bg-magenta |
Magenta background |
bg-cyan |
Cyan background |
bg-white |
White background |
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fansi-0.1.7.tar.gz.
File metadata
- Download URL: fansi-0.1.7.tar.gz
- Upload date:
- Size: 40.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.4 CPython/3.7.0 Darwin/18.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ec629970bd47c4601481248f6db4ac2cb091f6040efc6bbd03202a32e052ccf
|
|
| MD5 |
db038bbad0b1fae30546211a2c5d3002
|
|
| BLAKE2b-256 |
697839fa893f6c44fa433a8263c1285fdadf8359b9303142a6ac4dd3d61c1736
|
File details
Details for the file fansi-0.1.7-py3-none-any.whl.
File metadata
- Download URL: fansi-0.1.7-py3-none-any.whl
- Upload date:
- Size: 272.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.4 CPython/3.7.0 Darwin/18.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ec04b656e33e8c99e03ae5ea4ab599b549bc17204f57c017163ccc0941f838d
|
|
| MD5 |
52ae0645870353987e22ed68bdf98a1e
|
|
| BLAKE2b-256 |
f8f3f699b3974032ff16b7e16c442c7fa4abfe9400bf32199e58bf154c6e336c
|