Skip to main content

Large letter typography for Rich and Textual

Project description

Test Ruff Documentation

rich-typography

Large letter typography for Rich and Textual.

rich-typography example

Installation

Install with uv or your favorite PYPI package manager:

uv add rich-typography

Usage

from rich.console import Console
from rich_typography import Typography

console = Console()
text = Typography.from_markup("Hello from [purple]rich-typography[/purple]")
console.print(text)

rich-typography usage

Custom Markdown

Rich allows you to create your own Markdown renderable and overwrite how specific markdown blocks are rendered. With that we can modify this example to render H1 headings as Typography instead of Text.

from rich.markdown import Markdown as RichMarkdown, Heading as RichHeading
from rich.console import Console, RenderResult
from rich_typography import Typography


MARKDOWN = """
# This is an h1

Rich can do a pretty *decent* job of rendering markdown.

## This is an h2

1. This is a list item
2. This is another list item
"""


class Heading(RichHeading):
    def __rich_console__(self, *args, **kwargs) -> RenderResult:
        self.text.style = "red"
        if self.tag == "h1":
            text = Typography.from_text(self.text)
            text.justify = "center"
            yield text
        else:
            yield from super().__rich_console__(*args, **kwargs)


class Markdown(RichMarkdown):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.elements["heading_open"] = Heading



output = Markdown(MARKDOWN)

markdown example

Similar Projects

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

rich_typography-0.2.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rich_typography-0.2.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file rich_typography-0.2.0.tar.gz.

File metadata

  • Download URL: rich_typography-0.2.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rich_typography-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6113eb15dd98c1fdd29e045634a388b754a98edfc07b2e1c5b8267ba3b3c490e
MD5 d7d843c0677da7e0780cab201bb771aa
BLAKE2b-256 92488add54fbdde46795ff0d4fe6975427abb25bb3153cd01517d423e69d6068

See more details on using hashes here.

File details

Details for the file rich_typography-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rich_typography-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rich_typography-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cdd539b0bb82ef99533405386bec1baeab7adc04ee0370d4e46af8bfbe9045f
MD5 2e96af5c4f9df374e07076dd9a88f0a2
BLAKE2b-256 e0271c8a34082a2712073cc048b796dd66ec8e79f45dc66abd9cbf0e4f300a39

See more details on using hashes here.

Supported by

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