all repos — site @ 7f62efe6bc667c7cb11a94f850da2509241d646a

source for my site, found at icyphox.sh

bin/old/plaintext.sh (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
#!/bin/sh

if ! command -v lynx
then
    printf '%s\n' "lynx not found, not going to run"
    exit
fi

for p in build/blog/**/index.html; do
    ppath="${p%%\/index.html}"
    pname="${ppath##build\/blog\/}"

    temp="$ppath/temp.html"
    # Not POSIX, I know
    sed -e '29,34d' "$p" > "$temp"
    cat "$temp" | awk -v OFS='\n\n' '/class="muted"/{n=3}; n {n--; next;} 1' > "$temp.new"
    mv "$temp.new" "$temp"

    txt="pages/txt/$pname.txt"
    lynx -dump "$temp" | tail -n +1 > "$txt"
    rm "$temp"
    sed -i 's/file:\/\/\//https:\/\/icyphox\.sh\//' "$txt"
done