Format an input stream using the section character
Project description
Section-character format
This tool and library convert simple formatting codes that are based on the section character (§
) to standard ANSI escape codes.
These formatting codes are inspired by the ones used in Minecraft.
Formatting codes
16 colors are available:
To set the background color, prefix the color letter with g
(ex: §g1
for a blue background)
In addition to color codes, several other formatting codes are available:
§l
- Bold text§u
- Underlined text§v
- Reverse the background and foreground color§r
- Reset the formatting
Installation
This project can be installed via pip
:
pip install sformat
Tool usage
The sformat
tool can be used to format text by piping it to its standard input:
$ echo "§aHello §bWorld§r!" | sformat
Hello World! (in color)
Library usage
Simply use the format
function from sformat.formatter
:
from sformat.formatter import format
raw_text = "§aHello §bWorld§r!"
colored_text = format(raw_text)
print(colored_text) # The text will be displayed in color
License
This project is licensed under the GNU GPLv3 license.
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.