Skip to main content

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.

Metadata

Release files for sh40-zenith 0.10.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 sh40-zenith 0.10.0
File Size Uploaded
sh40_zenith-0.10.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sh40-zenith 0.10.0
File Interpreter ABI Platform
sh40_zenith-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / sh40_zenith-0.10.0.tar.gz

Download URL sh40_zenith-0.10.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bfd5036117c25a2cb0ecb2e507b9c7b2898378e19e4681ca45a7b7d4db303c08
BLAKE2b-256 checksum
How to use checksums
0494591e77d6c434ae678bef28e4515251594d3abd3b49fa83861741f5c8e703
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / sh40_zenith-0.10.0-py3-none-any.whl

Download URL sh40_zenith-0.10.0-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca571cc879f1ac51395c93fdfcdc1f88a3cbd5c39fe41719025407c2ef579e69
BLAKE2b-256 checksum
How to use checksums
304c8e460e4c3bdef18f5cc574538c0b9c77ce6184c74d77ad7e866765c425f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

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