Skip to main content

Fluent string builder for micron markup

Project description

micron-builder

micron-builder is a small Python library for building micron markup strings programmatically.
It provides a fluent API for composing text fragments, headers, separators, and styles without manually handling all the Micron markup symbols.


✨ Features

  • Fluent API for building Micron markup strings
  • Support for:
    • Text fragments with color, background color, and formatting (bold, italic, underline)
    • Headers with indent levels
    • Separators and line breaks
    • Links (address + page)
    • Alignment (center, right)
    • Padding around text
  • Works with raw strings or the built-in Color enum
  • Easy to extend and compose

📦 Installation

pip install micron-builder

🚀 Usage

Here’s a quick example of how to use MicronBuilder:

from micron import MicronBuilder
from micron.colors import Color

builder = (
    MicronBuilder()
    .header("Welcome!", indent_level=1)
    .text(
        "This is bold red text",
        bold=True,
        color=Color.RED,
    )
    .breakline()
    .text("Centered and underlined", center=True, underline=True)
    .separator("=")
    .text(
        "Clickable link",
        address_link="example.com",
        page_link="index.mu",
        italic=True,
    )
)

print(builder.build())

This would output Micron markup like:

>Welcome!

`!`Ff00This is bold red text`f`!

`c
_`Centered and underlined`_
`a

-=

`[*`Clickable link`example.com:/page/index.mu]

Which renders appropriately in Micron-compatible renderers.

🎨 Colors

Colors can be specified as:

  • A 3-digit hex string (e.g. "f00", "0ff")

  • A Color enum value:

    from micron.colors import Color
    
    MicronBuilder().text("Hello", color=Color.AQUA)
    

🛠 Development

Clone the repo and install in editable mode:

git clone https://github.com/neoemit/micron.git
cd micron
pip install -e .

Run tests (if you add them later):

pytest

📜 License

MIT License.

Feel free to use in your own projects.

🙌 Contributing

Pull requests, bug reports, and suggestions are welcome!

Open an issue or submit a PR on GitHub.

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

micron_builder-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

micron_builder-0.1.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file micron_builder-0.1.1.tar.gz.

File metadata

  • Download URL: micron_builder-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for micron_builder-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b2b4754a63fb1c7875a4da6ff34b85e9e8ca5e4dd3ab6bb4f97c90dbb87a875b
MD5 b9b7cf5a5a49af49c932111a693b23c3
BLAKE2b-256 787e4de66fcc2f2d51ac15d41d6d0cff655a737036f2f7bdf3e858453eb2391d

See more details on using hashes here.

File details

Details for the file micron_builder-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: micron_builder-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for micron_builder-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e2e2136456f86d1f43a022efd5269b306e83144d6c8653351216ae509c75a04
MD5 99d44824205b51797b69233dd6fd84f1
BLAKE2b-256 ef0e14656b108e652b16bdf1250f1474f8644754ccebcbe8243957d243fcb6ae

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