Chris@494: #!/bin/bash Chris@494: Chris@494: css='' Chris@494: Chris@494: echo "$css" > topics.html Chris@494: cat intro.html >> topics.html Chris@494: Chris@494: pcat="" Chris@494: Chris@494: for x in topics/*.txt ; do Chris@494: Chris@494: b=`basename "$x" .txt` Chris@494: out="a-$b.html" Chris@494: Chris@494: echo "$css" > "$out" Chris@494: Chris@494: cat "$x" | perl -e ' Chris@494: $_ = join "", <>; Chris@494: s/^{[\w\s]+}//s; Chris@494: s/^(\s*)([A-Za-z][^\n]*)/$1
$1/gs; Chris@494: s/^\n*([^<\n])/\n
$1/gs; Chris@494: s/^\n*(<[^p])/\n
$1/gs;
Chris@494: s/([^\n])\n\n/$1<\/p>\n\n/gs;
Chris@494: s/([^>\n])\n*$/$1<\/p>\n\n/gs;
Chris@496: s/\[\[([^\|]*)\|([^\]]*)\]\]/$2<\/a>/gs;
Chris@494: s/\[\[([^\|\]]*)\]\]/$1<\/a>/gs;
Chris@494: s/\b_([^_]+)_\b/$1<\/i>/gs;
Chris@494: s/@(\w[^@]+)@/ |" | sed 's/<\/h2>/<\/a><\/p>/' >> topics.html
Chris@494:
Chris@494: done
Chris@494:
$1<\/code>/gs;
Chris@494: s/---/—/gs;
Chris@494: s/--/–/gs;
Chris@494: s/
/
/gs;
Chris@494: s/<\/h2><\/p>/<\/h2>/gs;
Chris@494: print;
Chris@494: ' >> "$out"
Chris@494:
Chris@494: category=`grep '^{.*}$' "$x" | sed 's/[{}]//g'`
Chris@494:
Chris@494: if [ "$category" != "$pcat" ]; then
Chris@494: echo "
$category
" >> topics.html
Chris@495: pcat="$category"
Chris@494: fi
Chris@494:
Chris@494: grep '' "$out" | sed "s|
|