shuppy (@delan) [archived]

“let’s make a static site generator in shell scripts”, she said

shell script that uses ripgrep and sed to stitch together html files with the page title in the header and mtime in the footer, but first we have to check if we have gnu or bsd versions of stat(1) + date(1). for gnu we need “date -ud \@$(stat -c \%Y -- "$1") +\%FT\%RZ”, while for bsd we need “date -jr $(stat -f \%m -- "$1") +\%FT\%RZ”.

“it will be fun and lightweight”, she said

shuppy (@delan) [archived]

nabijaczleweli’s blogn_t.h, with a handful of html fragments in #define macros. for example, BLOGN_T_FOOTER() contains the words “[…] Nit-pick? Correction? Improvement? Annoying? Cute? Anything? Don'<!--'-->t hesitate to […]”, while HEADING_S(level, hid, style, ...) expands to “<h##level id=STR(hid) style>HEADING_LINK(hid) __VA_ARGS__</h##level>”.

tbh this fixed-function static site generator pales in comparison to @nabijaczleweli’s blogue, which uses the c preprocessor(!) to stitch together its html.

notice how Don't has to be spelled Don'<!--'-->t :)

shuppy (@delan) [archived]

ended up replacing most of that with soupault

replacing a shell-and-sed-based abomination with “exec soupault”

soupault is a pretty neat static site generator that works with html trees instead of the usual markup-plus-yaml-front-matter.

shuppy (@delan) [archived]

ok i fibbed a little

“mtime.sh”, a 48-line shell script where almost half of that is detecting whether you have the gnu or bsd version of stat(1) and date(1)

i still have a shell script for the “last modified” line on each page, which continues to be unlucky enough to rely on two (2) commands that are completely incompatible between gnu and bsd.

shuppy (@delan) [archived]

soupault respects my freedom to write sketchy html

changes made to the html output after switching to soupault, notably, implicit tags are now explicit (probably good for old browser compat, since not all parsers followed the current whatwg rules) and unquoted attributes are now quoted (see above), but sadly comments are stripped

it’s weird that the default setting pretty_print_html=true makes unsafe whitespace changes that can affect text nodes in very visible ways depending on css, and it really needs a “don’t strip comments” option

but otherwise soupault’s html processing seems good and non-invasive!