#!/usr/bin/env bash

for talon in `find examples -name '*.talon'`; do
  has_context=`awk 'BEGIN{found=0} /^-$/{found=1} END{print found}' "$talon"`
  if [ "$has_context" == "1" ]; then
    header_title="Context ${talon#examples/}"
    header_bar=`echo "$header_title" | sed 's/./=/g'`
    echo $header_bar
    echo $header_title
    echo $header_bar
    echo
    awk 'BEGIN{found=0} /^-$/{found=1} {if (! found) print}' "$talon"
    echo '-'
    echo
    echo '---'
    echo
    echo
  fi
done
