https://github.com/Pjt727/Html2FastHtml
https://github.com/Pjt727/Html2FastHtml
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Pjt727/Html2FastHtml
- Owner: Pjt727
- License: mit
- Created: 2024-08-18T00:21:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-13T09:28:49.000Z (9 months ago)
- Last Synced: 2025-02-13T10:30:39.595Z (9 months ago)
- Language: Python
- Size: 690 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-fasthtml - HTML 2 FastHTML: Third-party
- awesome-fasthtml - HTML 2 FastHTML: Third-party
README
# Html2FastHtml
Note for full support and continuous use [HTMLtoFT](https://h2f.answer.ai/).
This is small server meant to run locally allowing you to convert HTML to FastHTML components.
The web server is made with [FastHTML](https://github.com/AnswerDotAI/fasthtml "fasthtml github") and
uses [ruff](https://github.com/astral-sh/ruff "Ruff github") as a code formatter by default.
This currently does not use FastHTML functions to convert HTML;
it works by parsing the input into a tree using python's HTML parser and then traverses that tree
generating FastHTML components.
Once the FastHTML component string is done it writes it to a file and then formats it.
Any formatter configuration you wish to apply should work like normal.
There are edge cases where it might not generate the correct HTML.
# demo

# setup
- Clone the repository
- Install dependencies (pip venv example below)
- `python -m venv venv` (creates virtual environment)
- windows: `.\venv\Scripts\activate` OR Mac/Linux `source venv/bin/activate` (activates the virtual environment)
- `pip install -r requirement.txt` (installs required libraries: FastHTML and ruff)
- run the website locally `python main.py`
# configuration
- The formatter can be configured with the following environment variables to all for different auto formatters
- `PATH_TO_FILE` the temp file to write the code for formatting ex: `out/fasthtml.py`
- `AUTO_FORMATTER_CMD` the command to format said file ex: `ruff format out/fasthtml.py`