all repos — site @ 19809279de2c0becb80979379676748d1e13523d

source for my site, found at icyphox.sh

bin/plaintext.sh (view raw)

 1#!/bin/sh 
 2
 3if ! command -v lynx
 4then
 5    printf '%s\n' "lynx not found, not going to run"
 6    exit
 7fi
 8
 9for p in build/blog/**/index.html; do
10    ppath="${p%%\/index.html}"
11    pname="${ppath##build\/blog\/}"
12
13    temp="$ppath/temp.html"
14    # Not POSIX, I know
15    sed -e '29,34d' "$p" > "$temp"
16    cat "$temp" | awk -v OFS='\n\n' '/class="muted"/{n=3}; n {n--; next;} 1' > "$temp.new"
17    mv "$temp.new" "$temp"
18
19    txt="pages/txt/$pname.txt"
20    lynx -dump "$temp" | tail -n +1 > "$txt"
21    rm "$temp"
22    sed -i 's/file:\/\/\//https:\/\/icyphox\.sh\//' "$txt"
23done