html2term


Namehtml2term JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryParse minimal HTML-like markup into ANSI-styled terminal output
upload_time2025-08-14 08:15:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseApache License (2.0)
keywords html terminal ansi color style cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # html2term

html2term is a lightweight Python library that converts minimal HTML-like markup into ANSI-styled terminal output. It supports text styles, colors (including truecolor hex), layout tags, and nested formatting, all with zero external dependencies and full cross-platform compatibility.

[![PyPI version](https://badge.fury.io/py/html2term.svg)](https://badge.fury.io/py/html2term)

## ✨ Features

-   **Text Styles**: `<b>`, `<i>`, `<u>`, `<strike>`, `<blink>`.
-   **Semantic Tags**: `<strong>` (bold) and `<em>` (italic).
-   **16 Standard Colors**: `<red>`, `<green>`, `<bg-blue>`, etc.
-   **Truecolor (24-bit)**: Hex color support like `<#RRGGBB>` and `<bg-#RRGGBB>`.
-   **Layout**: Line breaks (`<br>`) and tabs (`<tab>`).
-   **Nested Tags**: `<b><red>Important!</red></b>` works as expected.
-   **Cross-Platform**: Works on Windows, macOS, and Linux.
-   **Zero Dependencies**: Only uses the Python standard library.

## 💾 Installation

Install `html2term` directly from PyPI:

```bash
pip install html2term
```

## 🚀 Usage

The package provides a simple function `printc` to parse and print styled text directly to your terminal.

```python
from html2term import printc

# --- Basic Usage ---
printc("<b>Hello, <green>World</green>!</b>")
printc("<i>This is <u>very</u> important information.</i>")

# --- Nested Styles ---
printc("<b>This is bold, but <red>this part is also red.</red></b>")

# --- Hex Colors (Truecolor) ---
printc("<#ff00ff>This is magenta text.</#ff00ff>")
printc("<bg-#003366>Dark blue background.</bg-#003366>")
printc("<b><#ffff00>Combine styles with hex colors!</#ffff00></b>")

# --- Layout ---
printc("First line.<br/>Second line.")
printc("Column 1<tab/>Column 2")
```

You can also use the `convert()` function if you need the raw string with ANSI codes.

```python
from html2term import convert

ansi_string = convert("<b><blue>I am a string</blue></b>")
print(ansi_string)
# Output: '\x1b[1m\x1b[34mI am a string\x1b[0m\x1b[1m\x1b[0m'
```

## 🏷️ Supported Tags

### Styles
- `<b>`, `<strong>` - Bold
- `<i>`, `<em>` - Italic
- `<u>` - Underline
- `<strike>` - Strikethrough
- `<blink>` - Blinking text

### Foreground Colors
- **Standard**: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `default`
- **Hex**: `<#RRGGBB>` (e.g., `<#ff7f50>`)

### Background Colors
- **Standard**: `bg-black`, `bg-red`, `bg-green`, etc.
- **Hex**: `<bg-#RRGGBB>` (e.g., `<bg-#0a0a0a>`)

### Layout
- `<br>`, `<br/>`, `<br />` - Newline
- `<tab>`, `<tab/>`, `<tab />` - Tab character

## 🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/Nikityyy/html2term/issues).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "html2term",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "html, terminal, ansi, color, style, cli",
    "author": null,
    "author_email": "Nikita Berger <bergernikita1807@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f2/a8/1a280672c79d997c1dd5a421fa360c0d50780427a725f6c2679a69887aec/html2term-1.0.0.tar.gz",
    "platform": null,
    "description": "# html2term\r\n\r\nhtml2term is a lightweight Python library that converts minimal HTML-like markup into ANSI-styled terminal output. It supports text styles, colors (including truecolor hex), layout tags, and nested formatting, all with zero external dependencies and full cross-platform compatibility.\r\n\r\n[![PyPI version](https://badge.fury.io/py/html2term.svg)](https://badge.fury.io/py/html2term)\r\n\r\n## \u2728 Features\r\n\r\n-   **Text Styles**: `<b>`, `<i>`, `<u>`, `<strike>`, `<blink>`.\r\n-   **Semantic Tags**: `<strong>` (bold) and `<em>` (italic).\r\n-   **16 Standard Colors**: `<red>`, `<green>`, `<bg-blue>`, etc.\r\n-   **Truecolor (24-bit)**: Hex color support like `<#RRGGBB>` and `<bg-#RRGGBB>`.\r\n-   **Layout**: Line breaks (`<br>`) and tabs (`<tab>`).\r\n-   **Nested Tags**: `<b><red>Important!</red></b>` works as expected.\r\n-   **Cross-Platform**: Works on Windows, macOS, and Linux.\r\n-   **Zero Dependencies**: Only uses the Python standard library.\r\n\r\n## \ud83d\udcbe Installation\r\n\r\nInstall `html2term` directly from PyPI:\r\n\r\n```bash\r\npip install html2term\r\n```\r\n\r\n## \ud83d\ude80 Usage\r\n\r\nThe package provides a simple function `printc` to parse and print styled text directly to your terminal.\r\n\r\n```python\r\nfrom html2term import printc\r\n\r\n# --- Basic Usage ---\r\nprintc(\"<b>Hello, <green>World</green>!</b>\")\r\nprintc(\"<i>This is <u>very</u> important information.</i>\")\r\n\r\n# --- Nested Styles ---\r\nprintc(\"<b>This is bold, but <red>this part is also red.</red></b>\")\r\n\r\n# --- Hex Colors (Truecolor) ---\r\nprintc(\"<#ff00ff>This is magenta text.</#ff00ff>\")\r\nprintc(\"<bg-#003366>Dark blue background.</bg-#003366>\")\r\nprintc(\"<b><#ffff00>Combine styles with hex colors!</#ffff00></b>\")\r\n\r\n# --- Layout ---\r\nprintc(\"First line.<br/>Second line.\")\r\nprintc(\"Column 1<tab/>Column 2\")\r\n```\r\n\r\nYou can also use the `convert()` function if you need the raw string with ANSI codes.\r\n\r\n```python\r\nfrom html2term import convert\r\n\r\nansi_string = convert(\"<b><blue>I am a string</blue></b>\")\r\nprint(ansi_string)\r\n# Output: '\\x1b[1m\\x1b[34mI am a string\\x1b[0m\\x1b[1m\\x1b[0m'\r\n```\r\n\r\n## \ud83c\udff7\ufe0f Supported Tags\r\n\r\n### Styles\r\n- `<b>`, `<strong>` - Bold\r\n- `<i>`, `<em>` - Italic\r\n- `<u>` - Underline\r\n- `<strike>` - Strikethrough\r\n- `<blink>` - Blinking text\r\n\r\n### Foreground Colors\r\n- **Standard**: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `default`\r\n- **Hex**: `<#RRGGBB>` (e.g., `<#ff7f50>`)\r\n\r\n### Background Colors\r\n- **Standard**: `bg-black`, `bg-red`, `bg-green`, etc.\r\n- **Hex**: `<bg-#RRGGBB>` (e.g., `<bg-#0a0a0a>`)\r\n\r\n### Layout\r\n- `<br>`, `<br/>`, `<br />` - Newline\r\n- `<tab>`, `<tab/>`, `<tab />` - Tab character\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nContributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/Nikityyy/html2term/issues).\r\n",
    "bugtrack_url": null,
    "license": "Apache License (2.0)",
    "summary": "Parse minimal HTML-like markup into ANSI-styled terminal output",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/Nikityyy/html2term/issues",
        "Homepage": "https://github.com/Nikityyy/html2term"
    },
    "split_keywords": [
        "html",
        " terminal",
        " ansi",
        " color",
        " style",
        " cli"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fd0fde90a8485f58c69475f1ebe54ee2b0f6e13e374cf65d0fec4ed297f3cefc",
                "md5": "a12a65dc2bedd031d143796268ed17a2",
                "sha256": "a41573b0f4bcd06f4cd86046fc842ff4384f3f62790482eaad98eda46c08ab4a"
            },
            "downloads": -1,
            "filename": "html2term-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a12a65dc2bedd031d143796268ed17a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8296,
            "upload_time": "2025-08-14T08:15:26",
            "upload_time_iso_8601": "2025-08-14T08:15:26.563224Z",
            "url": "https://files.pythonhosted.org/packages/fd/0f/de90a8485f58c69475f1ebe54ee2b0f6e13e374cf65d0fec4ed297f3cefc/html2term-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f2a81a280672c79d997c1dd5a421fa360c0d50780427a725f6c2679a69887aec",
                "md5": "f13c592d0cff2ff644d1e8a4b25485fb",
                "sha256": "8e9b09e5190fd0bef9c6013cc846527cd0ed3a2ea83fe8c1baf597aa39e6b23b"
            },
            "downloads": -1,
            "filename": "html2term-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f13c592d0cff2ff644d1e8a4b25485fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10050,
            "upload_time": "2025-08-14T08:15:27",
            "upload_time_iso_8601": "2025-08-14T08:15:27.953285Z",
            "url": "https://files.pythonhosted.org/packages/f2/a8/1a280672c79d997c1dd5a421fa360c0d50780427a725f6c2679a69887aec/html2term-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-14 08:15:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Nikityyy",
    "github_project": "html2term",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "html2term"
}
        
Elapsed time: 0.40179s