Skip to content

umckinney/simple-html-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple HTML Renderer

Python License: MIT Last Commit Repo Size

This project provides a class-based system for rendering HTML programmatically using Python.
It supports element nesting, attributes, self-closing tags, and inline vs. block-level elements.

Features

  • HTML tag rendering with indentation
  • Element content and attribute handling
  • Support for self-closing tags (e.g., br, hr, meta)
  • Specialized subclasses for common HTML tags (Html, Body, P, Title, etc.)
  • Link and header tag rendering
  • Readable, testable architecture with class-based design

Getting Started

To render an HTML structure, create instances of HTML elements and nest them using .append().

Example:

from html_render import Html, Body, P

page = Html()
body = Body()
body.append(P("Hello, world!"))
page.append(body)

with open("output.html", "w") as f:
    page.render(f)

Running Tests

Run the included tests with:

pytest test_html_render.py

License

This project is licensed under the MIT License.

About

A Python-based HTML rendering engine built from scratch using object-oriented principles.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages