Metadata-Version: 2.3
Name: html-tags
Version: 0.0.16
Summary: Concise, immutable HTML/SVG generation for Python. Zero dependencies.
Author: Deufel
Author-email: Deufel <MDeufel13@gmail.com>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.12
Project-URL: Changes, https://github.com/Deufel/html-tags/releases
Project-URL: Documentation, https://deufel.github.io/html-tags/
Project-URL: Repository, https://github.com/Deufel/html-tags
Description-Content-Type: text/markdown

# html-tags

![PyPI version](https://img.shields.io/pypi/v/html-tags)

> [!WARNING]
> Under active development — Mar 2026

Concise, immutable HTML/SVG generation for Python. Zero dependencies.

```python
from html_tags import setup_tags, setup_svg
setup_tags(); setup_svg()

page = Html(
    Head(Title("hello")),
    Body(
        H1("hello world", cls="title"),
        Svg(Circle(cx="50", cy="50", r="40")),
    )
)
```

Tags are immutable — call to add children or attributes:

```python
Div(cls="card")("content", id="main")
```

SVG elements self-close correctly (`<line />`) and shapes like `Circle` accept children for animations.

Datastar SSE helpers included:

```python
from html_tags import patch_elements, patch_signals, datastar_stream
```

## Gotchas

Keyword attribute names convert `_` to `-`:

```python
Circle(stroke_width="2")  # → stroke-width="2"
```

Dict keys pass through verbatim — use for special syntax or reserved names:

```python
Div({"data-on:click__once": "@post('/api')"})
FeBlend({"mode": "multiply"})
```

HTML void elements render without slash (`<br>`), SVG elements self-close (`<line />`).

## Security

Validates against injection, not HTML structure:

- `<script>`/`<style>` content checked for closing tag injection
- URL attributes reject `javascript:` and `vbscript:` schemes
- Attribute names validated against injection patterns
- Void elements reject children, `<html>` rejects nesting

Structural correctness (e.g. `<li>` inside `<ul>`) is left to the browser.

## Install

```
pip install html-tags
```

## License

MIT