all repos — site @ 4472540f33ca850dd973d84938a1b46e80eb4f05

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
 5basename() {
 6    dir=${1%${1##*[!/]}}
 7    dir=${dir##*/}
 8    dir=${dir%"$2"}
 9    base="${dir:-/}"
10}
11
12for p in pages/blog/*.md; do
13    basename "$p"
14    no_ext="${base%.*}"
15    [ "$base" != "_index.md" ] && {
16        pandoc --quiet -s -f "markdown+gutenberg" \
17            "$p" -o "pages/txt/$no_ext.txt"
18            # we have to 'mv' each file because of how pandoc treats
19            # output to plaintext. it's weird.
20            mv "pages/txt/$no_ext.txt" "pages/txt/$no_ext"
21    }
22done
23