CLI tool for converting text to HTML
Project description
thtml
thtml
(to HTML) is a CLI tool and Python package for converting text to HTML.
For example, to pipe a command through thtml
:
ls -al --color | thtml
<!doctype html><html>...</html>
Include --open
to send the HTML directly to your default browser:
ls -al --color | thtml --open
Full documentation: thtml.readthedocs.io
Installation
thtml
requires Python 3.8 or later.
pip install thtml
CLI usage
Pipe your command's output to thtml
:
COMMAND | thtml
If your command needs to run in a pseudo-terminal to emit formatting escape codes:
thtml COMMAND
By default, thtml
will write the HTML to stdout. To send the HTML to your default browser:
COMMAND | thtml --open
By default, thtml
will generate an entire HTML document. To return only a fragment:
COMMAND | thtml --scope fragment
Full documentation: thtml.readthedocs.io
Python usage
from thtml import write_html
with open("hello.html", "w") as writer:
write_html("\033[1mHello, world!\033[22m", writer)
Full documentation: thtml.readthedocs.io
👋 Hello!
Hello! I'm Cariad Eccleston and I'm an independent/freelance software engineer. If my work has value to you, please consider sponsoring.
If you ever raise a bug, request a feature or ask a question then mention that you're a sponsor and I'll respond as a priority. Thank you!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.