bin/plaintext.sh (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/bin/sh
# from the pure sh bible; see:
# https://github.com/dylanaraps/pure-sh-bible#get-the-base-name-of-a-file-path
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
|