Skip to main content

An intuitive, high performance HTML rendering framework

Project description

htmldoom

An intuitive, high performance HTML rendering framework

PyPI version PyPI version Build Status codecov Code style: black

Usage

A basic tag

>>> from htmldoom import render, elements as e
>>> 
>>> print(render(e.p(style="color='red'")("This is a paragraph")))
<p style="color:'red';">This is a paragraph</p>

A functional style foreach loop with a switch case

>>> from htmldoom import elements as e
>>> from htmldoom import functions as fn
>>> 
>>> tuple(fn.foreach(["good", "bad", "evil"])(
...     lambda x: fn.switch({
...         x == "good": lambda: e.span(style="color: green")(f"this is {x}"),
...         x == "bad": lambda: e.span(style="color: yellow")(f"this is {x}"),
...         x == "evil": lambda: e.span(style="color: red")(f"this is {x}"),
...         fn.Case.DEFAULT: lambda: fn.Error.throw(ValueError(x)),
...     })
... ))
(b'<span style="color: green">this is good</span>',
 b'<span style="color: yellow">this is bad</span>',
 b'<span style="color: red">this is evil</span>')

Find more examples here

Q/A

What is the goal here?

The primary goal is to make writing HTML pages cleaner, easier, safer and intuitive using Python.

What about performance?

Although performance is not the primary goal here, it should not be a roadblock. htmldoom is copying the syntax and some of the rendering properties of elm, an existing fast and purely functional programming language that specializes in rendering HTML in virtual doms. Elm does all the optimisation internally, which I'm believe can be implemented in Python to a great extent.
Furthermore, if we follow the the DOM size recommendations, i.e.

  • less than 1500 nodes total.
  • maximum depth of 32 nodes.
  • no parent node with more than 60 child nodes.
htmldoom should perform really well.

Plugins and ecosystem

  • moodlmth: Convert raw HTML pages into python source code

Contributing

Check out the contributing guidelines.

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

htmldoom-0.5.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

htmldoom-0.5-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file htmldoom-0.5.tar.gz.

File metadata

  • Download URL: htmldoom-0.5.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5

File hashes

Hashes for htmldoom-0.5.tar.gz
Algorithm Hash digest
SHA256 b53e4d1a9c0babcc5ff66c6d67d34de4921511c24086669a24aec4147522fcf5
MD5 4d2ee1c96d67272526b75443de05f834
BLAKE2b-256 99a293584d6720891c5a1dae8c2ac6a896604df8d6c89a6426e8e4e396e6d797

See more details on using hashes here.

File details

Details for the file htmldoom-0.5-py3-none-any.whl.

File metadata

  • Download URL: htmldoom-0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5

File hashes

Hashes for htmldoom-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ccf866454f4bfab27a83a66df137c469e21193ecb018c8b6493f9c933760b1eb
MD5 c71dc505ecd204b28d1604db93a61ad9
BLAKE2b-256 71146a0bb26b06cd306b3f791886b7147f1ccda726d85ead5d0aa7ca8687b033

See more details on using hashes here.

Supported by

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