Skip to main content

A markup language and color palette generators targeting the terminal.

Project description

zenith

Zenith

A markup language with a built-in color palette generator, made for the terminal.

pip install sh40-zenith

rule

Purpose

Zenith is a fast markup language meant to be readable and maximally accessible. Its syntax is inspired by BBCode, but it's meant to be readable enough that anyone can work with it with no background knowledge.

rule

Feature highlights

Extensive color & styling support for the terminal

ZML (the Zenith Markup Language) has support for 16, 256 and true color palettes, and supports both RGB triplets and HEX codes for the latter. A color can set the background if prefixed by @.

Zenith is implemented using Slate's terminal APIs, and as a result any color set in ZML will be backwards compatible for even the oldest (xterm-based) terminals!

If you only set a background but no foreground, ZML will choose either black or white depending on which will be more readable, in accordance to the W3C color contrast guidelines.

from zenith import zprint

zprint("[bold 141]Purple & bold,[/] Reset, [@#212121 grey]code,[/bg] and now only grey.")

Hyperlink support

ZML has a simple syntax to define web-like hyperlinks, which are supported by your terminal! Simply use the tilde symbol followed by a URI:

from zenith import zprint

zprint("This looks & functions like a terminal hyperlink: [blue underline ~https://google.com]Google[/]")

Customizable macros & aliases

We also support macros, which are python functions you can call to transform your unstyled markup content while it's being parsed. Here is a simple localization system, implemented using just one macro:

from zenith import zml_macro, zprint

LANG = "en"
LOCALIZATION = {
    "welcome": {
        "en": "Welcome to the project",
        "hu": "Üdv a projektben",
    }
}

@zml_macro
def loc(key: str) -> str:
  """Returns a localized string for the given key."""

  return LOCALIZATION[key][LANG]

zprint("This is localized: [!loc]welcome")

If you find yourself often reusing the same set of styles (even including macros), you can simply alias them:

from zenith import, zml_alias, zprint

zml_alias(title="!upper !gradient(72) bold")

zprint("[title]This is a cool title.[/title]")

Color palettes

Zenith supercharges Slate's 4-color palette generation by adding shades and aliasing them for use in ZML.

from slate import Color
from zenith import Palette, zprint

palette = Palette(Color.from_hex("#4A7A9F"))
palette.alias()

zprint(palette.render())

Palette example

rule

Documentation

Once the library gets to a settled state (near 1.0), documentation will be hosted both online and as a celx application. Until then peep the experiments folder, or check out some of the references by using python3 -m pydoc <name>.

rule

See also

This library is mostly supposed to power some higher level tools, so using it raw might not be ideal. Thankfully, we have two projects that can help with that:

  • Slate: The terminal management library at the core of many of Zenith's features.
  • Celadon: A TUI library that makes extensive use of ZML for widget configuration, and uses the palette generator for quick and great looking UIs.
  • celx: A hypermedia-driven TUI framework built on top of Celadon.

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

sh40_zenith-0.6.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

sh40_zenith-0.6.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file sh40_zenith-0.6.0.tar.gz.

File metadata

  • Download URL: sh40_zenith-0.6.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.9.18

File hashes

Hashes for sh40_zenith-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f90179117a79bc326c73f6cd1529d2c5c7c0cfc2b7535f2cf9a7ffa01c3df2c4
MD5 2d6fffd2f1e6a227e6e0d4db352683bc
BLAKE2b-256 f70ad2718f9b980fa2ceee46f7f11c97a9c930b4d6e6d3afd674f4dcab880341

See more details on using hashes here.

File details

Details for the file sh40_zenith-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: sh40_zenith-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.9.18

File hashes

Hashes for sh40_zenith-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86aa18029ce4b9bf55a05e38f5a08e53ea270b32d4a2eb245204194a76728aad
MD5 110aee95ce558825d1396843d48a4b13
BLAKE2b-256 7bcab2337608a72e6833ac910e2b1cb63625d7d1887fada3dfb916926319f85f

See more details on using hashes here.

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