Jun 27 2025
htag — Create html in the shell
htag tag-name [--attr-name attr-val]... [text-content]...
Create HTML tags and attributes in the shell.
The first argument must be the name of the tag. All other non-flag arguments are inserted into the tag as text content.
If the tag name is the only non-flag argument, then text is read from the STDIN.
Long flags are automatically converted into attributes, and all consume one argument as the attribute value.
Prints the created tag to the STDOUT.
Printing an empty tag:
$ htag p ""
> <p></p>
Printing some text:
$ htag p Some text
> <p>Some text</p>
$ htag p "Some text"
> <p>Some text</p>
$ echo "Some text" | htag p
> <p>Some text</p>
Adding attributes:
$ htag a "An anchor tag" --href "https://foobar.baz"
> <a href="https://foobar.baz">An anchor tag</a>
A more complicated example:
$ for FILE in $(ls)
do htag li "$FILE"
done | htag ul
> <ul><li>bin</li>
<li>doc</li>
<li>justfile</li>
<li>LICENSE</li>
<li>pandoc.yml</li>
<li>README.md</li>
<li>src</li></ul>
Source code can be found at https://github.com/ctwiebe23/htag.