Skip to content

COMP1010UNSW/pyhtml-enhanced

Folders and files

NameName
Last commit message
Last commit date
Apr 28, 2025
Jan 10, 2025
Apr 12, 2025
Feb 14, 2025
Apr 6, 2025
Apr 6, 2025
Sep 5, 2023
Jun 10, 2024
Nov 25, 2023
Apr 12, 2025
Apr 3, 2025
Apr 12, 2025
May 2, 2025
May 2, 2025

Repository files navigation

<PyHTML/>

A library for building HTML documents with a simple and learnable syntax, inspired by (and similar to) Cenk Altı's PyHTML library, but with improved documentation and type safety.

Learn more by reading the documentation, or try it out online!

Features

  • Inline documentation and type safety for all tags.

  • Editor support for many common tags (attribute suggestions).

  • A modern and readable codebase.

  • 100% test coverage.

Usage

>>> import pyhtml as p
>>> my_website = p.html(
...     p.head(
...         p.title("Hello, world!"),
...         p.script(src="http://example.com/script.js"),
...     ),
...     p.body(
...         p.h1("Hello, world!"),
...         p.p("This is my amazing website!"),
...     ),
... )
>>> print(str(my_website))
<!DOCTYPE html>
<html>
  <head>
    <title>
      Hello, world!
    </title>
    <script type="text/javascript" src="http://example.com/script.js"></script>
  </head>
  <body>
    <h1>
      Hello, world!
    </h1>
    <p>This is my amazing website!</p>
  </body>
</html>