Metadata-Version: 2.4
Name: mohtml
Version: 0.1.9
Summary: DSL for Python to HTML aimed at Marimo
Author: Vincent D. Warmerdam
License: MIT License
        
        Copyright (c) 2024 vincent d warmerdam 
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: repository, https://github.com/koaning/mohtml
Project-URL: issue-tracker, https://github.com/koaning/mohtml/issues
Project-URL: documentation, https://koaning.github.io/mohtml/
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4
Requires-Dist: marimo
Dynamic: license-file

<img src="imgs/icon.png" width="125" height="125" align="right" />

### `mohtml`

This project is all about a DSL to write HTML in Python. 

> This work is *heavily* inspired by [FastHTML](https://fastht.ml/).
> 
> I mainly made this to see if I could reimplement it easily and if I might be able to hack together a lightweight variant of the idea for [Marimo](https://marimo.app/). If you feel like giving folks credit, feel free to join the [FastHTML Discord](https://discord.gg/qcXvcxMhdP) and give them a high-five first. 

## Installation

You can install this project via uv/pip: 

```python
uv pip install mohtml
```

## Quick demo

With that out of the way, let's have a quick look what what the DSL is like.

```python
# You can import any HTML element this way
from mohtml import a, p, div, script, h1

div(
    script(src="https://cdn.tailwindcss.com"),
    h1("welcome to my blog", klass="font-bold text-xl"),
    p("my name is vincent", klass="text-gray-500 text-sm"),
    a("please check my site", href="https://calmcode.io", klass="underline")
)
```

This code will generate the following HTML:

```html
<div>
 <script src="https://cdn.tailwindcss.com">
 </script>
 <h1 class="font-bold text-xl">
  welcome to my blog
 </h1>
 <p class="text-gray-500 text-sm">
  my name is vincent
 </p>
 <a class="underline" href="https://calmcode.io">
  please check my site
 </a>
</div>
```

You can also render this HTML nicely from Marimo via: 

```python
myhtml = div(...)
mo.Html(f"{myhtml}")
```

## From here?

This is already pretty cool on it's own, but there are a few directions here. 

1. Maybe we can use this tool to make representations of objects nicer in Marimo.
2. Maybe we can come up with a nice way to turn these HTML objects into something reactive.
3. Maybe we can use this as an alternative for Jinja templates in some cases. Could be nice to make some simple dashboard-y UI components here.
