bigskysoftware / _hyperscript

a small scripting language for the web
BSD 2-Clause "Simplified" License
3.14k stars 149 forks source link

Minified Hyperscript code in .hs files #503

Open lynxionxs opened 11 months ago

lynxionxs commented 11 months ago

Can Hyperscript code in .hs files be minified ?

lynxionxs commented 11 months ago

I made a bash script to minify hyperscript code. Not ideal, but i don't have a better solution

#!/bin/bash

filename="$1"
output="hs-min.hs"

line=""
add_space=0

while read -r code_line; do
    if [[ $code_line != \--* ]]; then
        if [ $add_space -eq 1 ]; then
            line="$line "
            add_space=0
        fi
        line="$line$code_line"
        add_space=1
    fi
done <"$filename"

if [ $add_space -eq 1 ]; then
    line="$line "
fi

echo -n "$line" >"$output"