all repos — site @ 29fff4a8a012d48d9460e6560ad166de014422bc

source for my site, found at icyphox.sh

bin/plaintext.sh (view raw)

 1#!/bin/sh 
 2
 3# from the pure sh bible; see: 
 4# https://github.com/dylanaraps/pure-sh-bible#get-the-base-name-of-a-file-path
 5
 6for p in build/blog/**/index.html; do
 7    ppath="${p%%\/index.html}"
 8    pname="${ppath##build\/blog\/}"
 9
10    temp="$ppath/temp.html"
11    # Not POSIX, I know
12    sed -e '29,34d' "$p" > "$temp"
13    cat "$temp" | awk -v OFS='\n\n' '/class="muted"/{n=3}; n {n--; next;} 1' > "$temp.new"
14    mv "$temp.new" "$temp"
15
16    txt="pages/txt/$pname.txt"
17    lynx -dump "$temp" | tail -n +1 > "$txt"
18    rm "$temp"
19    sed -i 's/file:\/\/\//https:\/\/icyphox\.sh\//' "$txt"
20done