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
6mkdir -p build/txt
7for p in build/blog/**/index.html; do
8 ppath="${p%%\/index.html}"
9 pname="${ppath##build\/blog\/}"
10
11 temp="$ppath/temp.html"
12 # Not POSIX, I know
13 sed -e '29,34d' "$p" > "$temp"
14 cat "$temp" | awk -v OFS='\n\n' '/class="muted"/{n=3}; n {n--; next;} 1' > "$temp.new"
15 mv "$temp.new" "$temp"
16
17 txt="build/txt/$pname.txt"
18 lynx -dump "$temp" | tail -n +1 > "$txt"
19 rm "$temp"
20 sed -i 's/file:\/\/\//https:\/\/icyphox\.sh\//' "$txt"
21done