Skip to main content

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:

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.

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

sformat-0.1.0.tar.gz (14.3 kB view hashes)

Uploaded Source

Built Distribution

sformat-0.1.0-py3-none-any.whl (14.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page