micron-builder


Namemicron-builder JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryFluent string builder for micron markup
upload_time2025-08-23 14:15:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords micron builder colors ansi terminal
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
pip install micron-builder
```

## πŸš€ Usage

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

```python
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="aaabbbcccddd",
        page_link="index.mu",
        italic=True,
    )
)

print(builder.build())
```

This would output Micron markup like:

```

>Welcome!
`Ff00`!This is bold red text`!`f

`c
`_Centered and underlined`_
`a
-=

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

Which renders appropriately in Micron-compatible renderers.

New: use the raw(...) method to insert unescaped Micron markup directly

```python
from micron import MicronBuilder
from micron.colors import Color

builder = (
    MicronBuilder()
    .text("Some text", color=Color.GREEN)
    # raw() inserts the provided string exactly as-is into the output,
    # useful for injecting already-formed Micron markup.
    .raw("`!`Ff00This is raw micron markup`f`!")
)

print(builder.build())
```

This will include the raw markup verbatim in the output:

```
`F070Some text`f
`!`Ff00This is raw micron markup`f`!
```

## 🎨 Colors

Colors can be specified as:
- A **3-digit hex string** (e.g. `"f00"`, `"0ff"`)
- A `Color` enum value:

    ```python
    from micron.colors import Color

    MicronBuilder().text("Hello", color=Color.AQUA)
    ```

## πŸ›  Development

Clone the repo and install in editable mode:
```bash
git clone https://github.com/neoemit/micron-builder.git
cd micron-builder
pip install -e .
```

Run tests (if you add them later):
```bash
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](https://github.com/neoemit/micron).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "micron-builder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "micron, builder, colors, ansi, terminal",
    "author": null,
    "author_email": "Thomas La Mendola <thomas.lamendola@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/59/0e/a924b49a158c9bc8d9de6d7774d747b7dbf6709d1d40997691e2da50c300/micron_builder-0.1.3.tar.gz",
    "platform": null,
    "description": "# micron-builder\n\n**micron-builder** is a small Python library for building micron markup strings programmatically.  \nIt provides a fluent API for composing text fragments, headers, separators, and styles without manually handling all the Micron markup symbols.\n\n---\n\n## \u2728 Features\n\n- Fluent API for building Micron markup strings\n- Support for:\n  - **Text fragments** with color, background color, and formatting (bold, italic, underline)\n  - **Headers** with indent levels\n  - **Separators** and line breaks\n  - **Links** (address + page)\n  - **Alignment** (center, right)\n  - **Padding** around text\n- Works with raw strings or the built-in `Color` enum\n- Easy to extend and compose\n\n---\n\n## \ud83d\udce6 Installation\n\n```bash\npip install micron-builder\n```\n\n## \ud83d\ude80 Usage\n\nHere\u2019s a quick example of how to use `MicronBuilder`:\n\n```python\nfrom micron import MicronBuilder\nfrom micron.colors import Color\n\nbuilder = (\n    MicronBuilder()\n    .header(\"Welcome!\", indent_level=1)\n    .text(\n        \"This is bold red text\",\n        bold=True,\n        color=Color.RED,\n    )\n    .breakline()\n    .text(\"Centered and underlined\", center=True, underline=True)\n    .separator(\"=\")\n    .text(\n        \"Clickable link\",\n        address_link=\"aaabbbcccddd\",\n        page_link=\"index.mu\",\n        italic=True,\n    )\n)\n\nprint(builder.build())\n```\n\nThis would output Micron markup like:\n\n```\n\n>Welcome!\n`Ff00`!This is bold red text`!`f\n\n`c\n`_Centered and underlined`_\n`a\n-=\n\n`*`[Clickable link`aaabbbcccddd:/page/index.mu]`*\n```\n\nWhich renders appropriately in Micron-compatible renderers.\n\nNew: use the raw(...) method to insert unescaped Micron markup directly\n\n```python\nfrom micron import MicronBuilder\nfrom micron.colors import Color\n\nbuilder = (\n    MicronBuilder()\n    .text(\"Some text\", color=Color.GREEN)\n    # raw() inserts the provided string exactly as-is into the output,\n    # useful for injecting already-formed Micron markup.\n    .raw(\"`!`Ff00This is raw micron markup`f`!\")\n)\n\nprint(builder.build())\n```\n\nThis will include the raw markup verbatim in the output:\n\n```\n`F070Some text`f\n`!`Ff00This is raw micron markup`f`!\n```\n\n## \ud83c\udfa8 Colors\n\nColors can be specified as:\n- A **3-digit hex string** (e.g. `\"f00\"`, `\"0ff\"`)\n- A `Color` enum value:\n\n    ```python\n    from micron.colors import Color\n\n    MicronBuilder().text(\"Hello\", color=Color.AQUA)\n    ```\n\n## \ud83d\udee0 Development\n\nClone the repo and install in editable mode:\n```bash\ngit clone https://github.com/neoemit/micron-builder.git\ncd micron-builder\npip install -e .\n```\n\nRun tests (if you add them later):\n```bash\npytest\n```\n\n## \ud83d\udcdc License\n\nMIT License.\n\nFeel free to use in your own projects.\n\n## \ud83d\ude4c Contributing\n\nPull requests, bug reports, and suggestions are welcome!\n\nOpen an issue or submit a PR on [GitHub](https://github.com/neoemit/micron).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fluent string builder for micron markup",
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [
        "micron",
        " builder",
        " colors",
        " ansi",
        " terminal"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f85234012994b084feae6bc374676700ec7a88e5ff8db66f2847cff1c8558208",
                "md5": "2a98551f38c1f6a75716606bd6b12c79",
                "sha256": "adba20a06d3ccacae9c9e2a2f6560a277cc45fd5cb752dd35912b10324a5e5fa"
            },
            "downloads": -1,
            "filename": "micron_builder-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2a98551f38c1f6a75716606bd6b12c79",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 6578,
            "upload_time": "2025-08-23T14:15:05",
            "upload_time_iso_8601": "2025-08-23T14:15:05.754810Z",
            "url": "https://files.pythonhosted.org/packages/f8/52/34012994b084feae6bc374676700ec7a88e5ff8db66f2847cff1c8558208/micron_builder-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "590ea924b49a158c9bc8d9de6d7774d747b7dbf6709d1d40997691e2da50c300",
                "md5": "2092b982459c9c624c2c3dc494477fb3",
                "sha256": "313b239a0a9f7d17ad7a83a01cef09503f6f21dedd4d52a9f1b7efe4a5e052a4"
            },
            "downloads": -1,
            "filename": "micron_builder-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "2092b982459c9c624c2c3dc494477fb3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7441,
            "upload_time": "2025-08-23T14:15:06",
            "upload_time_iso_8601": "2025-08-23T14:15:06.427520Z",
            "url": "https://files.pythonhosted.org/packages/59/0e/a924b49a158c9bc8d9de6d7774d747b7dbf6709d1d40997691e2da50c300/micron_builder-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-23 14:15:06",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "micron-builder"
}
        
Elapsed time: 2.31471s