Skip to main content

Simple HTML Generation

Project description

minihtml - Simple HTML Generation

PyPI - Version

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minihtml-0.2.3.tar.gz (940.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minihtml-0.2.3-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file minihtml-0.2.3.tar.gz.

File metadata

  • Download URL: minihtml-0.2.3.tar.gz
  • Upload date:
  • Size: 940.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for minihtml-0.2.3.tar.gz
Algorithm Hash digest
SHA256 2c7419de9ffcd63f155b279c386129db71d4d2aa9df8ed8a49f61e8871eb6f99
MD5 9b8d1dd13e6cdbb9cccedd4156bb133e
BLAKE2b-256 baf63f246f9bd90ee32774fa2fed9d4411382f6252d53842158cddf2a8a51fb1

See more details on using hashes here.

File details

Details for the file minihtml-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: minihtml-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for minihtml-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ecf34672fbd22ace997ed2a1806b6b295c0b88757c7f8edf4e7695b66e0a0c8
MD5 f6ad779311d32f4062b714bc5ffb1136
BLAKE2b-256 a64c85b4ec3f1a2122981b07dbbb6916e87be6254f49ee587f03b50308bf3d70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page