Metadata-Version: 2.4
Name: philiprehberger-ansi-style
Version: 0.2.0
Summary: Terminal text styling with zero dependencies and TTY detection.
Project-URL: Homepage, https://github.com/philiprehberger/py-ansi-style#readme
Project-URL: Repository, https://github.com/philiprehberger/py-ansi-style
Project-URL: Issues, https://github.com/philiprehberger/py-ansi-style/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-ansi-style/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: ansi,color,console,style,terminal
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# philiprehberger-ansi-style

[![Tests](https://github.com/philiprehberger/py-ansi-style/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-ansi-style/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-ansi-style.svg)](https://pypi.org/project/philiprehberger-ansi-style/)
[![Last updated](https://img.shields.io/github/last-commit/philiprehberger/py-ansi-style)](https://github.com/philiprehberger/py-ansi-style/commits/main)

Terminal text styling with zero dependencies and TTY detection.

## Installation

```bash
pip install philiprehberger-ansi-style
```

## Usage

```python
from philiprehberger_ansi_style import red, green, blue, bold, underline

print(red("Error: something went wrong"))
print(green("Success!"))
print(bold(blue("Important message")))
```

### Color functions

```python
from philiprehberger_ansi_style import (
    red, green, blue, yellow, cyan, magenta, white, gray,
)

print(red("Red text"))
print(green("Green text"))
print(blue("Blue text"))
print(yellow("Yellow text"))
print(cyan("Cyan text"))
print(magenta("Magenta text"))
print(white("White text"))
print(gray("Gray text"))
```

### Style functions

```python
from philiprehberger_ansi_style import bold, dim, underline, italic

print(bold("Bold text"))
print(dim("Dim text"))
print(underline("Underlined text"))
print(italic("Italic text"))
```

### Custom styling

```python
from philiprehberger_ansi_style import style

print(style("Alert", fg="red", bold=True))
print(style("Note", fg="cyan", underline=True))
print(style("Highlight", fg="white", bg="blue", bold=True))
```

### Strip ANSI codes

```python
from philiprehberger_ansi_style import red, strip_ansi

styled = red("hello")
plain = strip_ansi(styled)  # "hello"
```

## API

| Function | Description |
|---|---|
| `red(text)` | Apply red foreground color |
| `green(text)` | Apply green foreground color |
| `blue(text)` | Apply blue foreground color |
| `yellow(text)` | Apply yellow foreground color |
| `cyan(text)` | Apply cyan foreground color |
| `magenta(text)` | Apply magenta foreground color |
| `white(text)` | Apply white foreground color |
| `gray(text)` | Apply gray foreground color |
| `bold(text)` | Apply bold weight |
| `dim(text)` | Apply dim intensity |
| `underline(text)` | Apply underline decoration |
| `italic(text)` | Apply italic style |
| `style(text, *, fg, bg, bold, dim, underline)` | Apply custom combination of colors and styles |
| `strip_ansi(text)` | Remove all ANSI escape codes from text |

## Development

```bash
pip install -e .
python -m pytest tests/ -v
```

## Support

If you find this project useful:

⭐ [Star the repo](https://github.com/philiprehberger/py-ansi-style)

🐛 [Report issues](https://github.com/philiprehberger/py-ansi-style/issues?q=is%3Aissue+is%3Aopen+label%3Abug)

💡 [Suggest features](https://github.com/philiprehberger/py-ansi-style/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)

❤️ [Sponsor development](https://github.com/sponsors/philiprehberger)

🌐 [All Open Source Projects](https://philiprehberger.com/open-source-packages)

💻 [GitHub Profile](https://github.com/philiprehberger)

🔗 [LinkedIn Profile](https://www.linkedin.com/in/philiprehberger)

## License

[MIT](LICENSE)
