Coloring and formatting text in ANSI-compatible terminals
Project description
InkCode - ANSI Text Colorizer and Formatter
InkCode
is a Python function that colorizes and formats text for ANSI-compatible terminals. It provides a simple way to enhance the appearance of text by adding color and formatting options.
Usage
from inkcode import ink_text
text = "Hello, world!"
color = "green"
format = "bold"
result = ink_text(text, color, format)
print(result)
This example will print the text "Hello, world!" in bold green.
Parameters
text
(str): The text to be colorized and formatted.color
(str): The desired text color. Available colors are black, red, green, yellow, blue, magenta, cyan, and white.format
(str, optional): The desired text format. Available formats are bold, faint, italic, underline, blink, reverse, crossed_out, double_underline, framed, encircled, overlined, and reset_all. Defaults to None.
Return Value
The function returns a string containing the colorized and formatted text.
Examples
# Colorize text in red
red_text = ink_text("Error!", "red")
print(red_text)
# Colorize text in red another way and format with bold
print(ink_text("Error!", "red", "bold"))
# Format text with underline and color it blue
blue_underline_text = ink_text("Important", "blue", "underline")
print(blue_underline_text)
Notes
- This function uses ANSI escape codes to apply color and formatting. It may not work properly in environments that do not support ANSI escape codes.
Feel free to use and modify this function to suit your needs. If you encounter any issues or have suggestions for improvement, please let us know.
Note: Make sure to handle exceptions appropriately when using this function to prevent unexpected behavior.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file InkCode-1.0.tar.gz
.
File metadata
- Download URL: InkCode-1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c74d20b780367e9a11ccca015402f8b38cb8ec053037647112bdbe98bba9dce1 |
|
MD5 | ea0882a1db526f08642cc5ffd47b7154 |
|
BLAKE2b-256 | dfdf95ba3ad560d12025e3850e06aff1bacdffe9c4e3b13599b72c02a7ed2557 |
File details
Details for the file InkCode-1.0-py3-none-any.whl
.
File metadata
- Download URL: InkCode-1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d51c0dce69543811e26a1f5735c425c8e7ba552414ca83b5f094cfb5a53dfee |
|
MD5 | a1cb1026bb39826212b7e05082c0b3f3 |
|
BLAKE2b-256 | b55b2271bd5bc4434278a75185420d842a26b07b47ef03064e89b08f74f03332 |