minihtml - Simple HTML Generation
minihtml is a library to generate HTML documents from Python. It aims to provide an API that allows you to define the structure of an HTML document in a succinct and natural way.
By building up nested HTML elements using context managers, you can combine HTML generation with control flow statements in a way that is easy to read and does not obscure the structure of the resulting HTML document.
Installation
Install the minihtml package from PyPI:
pip install minihtml
or
uv add minihtml
Example
A basic "hello, world" example:
>>> from minihtml.tags import html, head, title, body, div, p, a, img
>>> with html(lang="en") as elem:
... with head:
... title("hello, world!")
... with body, div["#content main"]:
... p("Welcome to ", a(href="https://example.com/")("my website"))
... img(src="hello.png", alt="hello")
...
<...>
>>> print(elem)
<html lang="en">
<head>
<title>hello, world!</title>
</head>
<body>
<div id="content" class="main">
<p>Welcome to <a href="https://example.com/">my website</a></p>
<img src="hello.png" alt="hello">
</div>
</body>
</html>
Links
License
Minihtml is released under the MIT license. See LICENSE for more information.
Release files for minihtml 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| minihtml-0.2.3.tar.gz | 940.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| minihtml-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 954.0 kB
Release files / minihtml-0.2.3.tar.gz
| Download URL | minihtml-0.2.3.tar.gz |
|---|---|
| Size | 940.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c7419de9ffcd63f155b279c386129db71d4d2aa9df8ed8a49f61e8871eb6f99
|
|
BLAKE2b-256 checksum How to use checksums |
baf63f246f9bd90ee32774fa2fed9d4411382f6252d53842158cddf2a8a51fb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|
Release files / minihtml-0.2.3-py3-none-any.whl
| Download URL | minihtml-0.2.3-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ecf34672fbd22ace997ed2a1806b6b295c0b88757c7f8edf4e7695b66e0a0c8
|
|
BLAKE2b-256 checksum How to use checksums |
a64c85b4ec3f1a2122981b07dbbb6916e87be6254f49ee587f03b50308bf3d70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|