#!/bin/bash

COURSE=$1
INPUT="$COURSE".tex
OUTLINE="$COURSE"-long-outline.txt

echo COURSE=$COURSE > "$OUTLINE"

echo VERSION=$(grep '\\newcommand{\\version}' $INPUT \
    | sed -e s/'\\newcommand{\\version}{'//g | sed -e s/'}'//g) \
    >> $OUTLINE	
echo TITLE="$(grep 'coursetitle' $INPUT \
	| sed -e s/'\\newcommand{\\coursetitle}{'//g | sed -e s/'}'//g)" \
    >> $OUTLINE	
sed -e s/'\\contentsline '//g \
    -e s/'{\\numberline '//g \
    -e s/'{section}'/'    '/g \
    -e s/'{chapter}'/CHAPTER:/g \
    -e 's/{chapter.*//' \
    -e 's/{section.*//' \
    "$COURSE".toc >> "$OUTLINE"
echo I made: "$OUTLINE"
