Skip to main content

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:

colors

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.

Metadata

Release files for sformat 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sformat 0.1.0
File Size Uploaded
sformat-0.1.0.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sformat 0.1.0
File Interpreter ABI Platform
sformat-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / sformat-0.1.0.tar.gz

Download URL sformat-0.1.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7db54a56f043aa372c1c7011a38fc39ba2ef7c0a6f6d06124530dea40523e0bb
BLAKE2b-256 checksum
How to use checksums
d8c32f778313b86daf6056ad033c24fec3d526e5019e8b2276272dfa0a3f8ae7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sformat-0.1.0-py3-none-any.whl

Download URL sformat-0.1.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
071c8c69311552fdbdb8ad1f0f440ac0a75da70c1db5d6d5d81a785b93dbe170
BLAKE2b-256 checksum
How to use checksums
c5295f192f861c8abc9154ea2671c109f344251f0e0083b781acfb3a46c14de7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page