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.
Source Distribution
Built Distribution
File details
Details for the file sformat-0.1.0.tar.gz
.
File metadata
- Download URL: sformat-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7db54a56f043aa372c1c7011a38fc39ba2ef7c0a6f6d06124530dea40523e0bb |
|
MD5 | f17e34742edde3b74fe4061752813dba |
|
BLAKE2b-256 | d8c32f778313b86daf6056ad033c24fec3d526e5019e8b2276272dfa0a3f8ae7 |
File details
Details for the file sformat-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: sformat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 071c8c69311552fdbdb8ad1f0f440ac0a75da70c1db5d6d5d81a785b93dbe170 |
|
MD5 | 8a944a6c900650611ff302fcd2f50d6d |
|
BLAKE2b-256 | c5295f192f861c8abc9154ea2671c109f344251f0e0083b781acfb3a46c14de7 |