#!/bin/sh
# Creates an ASXII version of the wiki.

echo "making TXT"

./make_stats.sh

rm -rf txt
mkdir txt

for f in *.md; do
  echo $f

  fname=$(echo "$f" | sed "s/\.md//g")
  f2="txt/${fname}.txt"

  cat $f | cmark-gfm -e table > __tmp.html && links -html-numbered-links 1 -dump __tmp.html | sed "s/file:\/\/.*less_retarded_wiki\///g" >> $f2
done

rm __tmp.html

echo "making single TXT"

echo "LESS RETARDED WIKI" > lrs.txt
echo "by drummyfish, released under CC0 1.0, public domain" >> lrs.txt

for f in txt/*.txt; do
  echo $f

  fname=$(echo "$f" | sed "s/\.txt//g" | sed "s/txt\///g")

  echo "--------------------------------------------------------------------------------" >> lrs.txt
  echo "$fname:" >> lrs.txt

  cat $f >> lrs.txt
done

echo "done"
