#! /bin/sh
#########################################################################
#                                                                       #
#               ,               /\    ,                                 #
#              ||        ,     (  )  ||                                 #
#             =||=  _-_  \\ /`   // =||= ,._-_  _-_   _-_               #
#              ||  || \\  \\    //   ||   ||   || \\ || \\              #
#              ||  ||/    /\\  /(    ||   ||   ||/   ||/                #
#              \\, \\,/  /  \; {___  \\,  \\,  \\,/  \\,/               #
#                                                                       #
#                                                                       #
#                                                                       #
#                 Copyright (c) 1993  Jan van der Steen                 #
#              Centre for Mathematics and Computer Science              #
#                      Amsterdam, the Netherlands                       #
#                                                                       #
#-----------------------------------------------------------------------#
#   You are not allowed to use this software in commercial software.    #
#   You are allowed to use this software in free software under the     #
#   condition that you maintain this integral message in the source.    #
#-----------------------------------------------------------------------#
# File    : tex2tree                                                         #
# Purpose : Convert a sgf2misc TeX file produced by a gobase tree.sgf	#
# Version : 1.2                                                         #
# Modified: 18 May 1994 16:39:12                                                     #
# Author  : Jan van der Steen (jansteen@cwi.nl)                         #
#########################################################################

if [ $# -ne 1 ]
then
    echo "Usage: tex2tree filename"
    exit 1
fi
file="`basename $1 .tex`"

cat $1 | sed							\
		-e '/^\\documentstyle/s/sgf/sgf,gobasetree/'	\
		-e '/^\\[bw]n/s/$/\\par/'			\
		-e 's/^ Black: \(.*\)/\\Black{\1}/'		\
		-e 's/^ White: \(.*\)/\\White{\1}/'		\
		-e 's/^ Date : \(.*\)/\\Date {\1}/'		\
		-e 's/^ Game : \(.*\)/\\Game {\1}/'		\
		-e 's/^ Move : \(.*\)/\\Move {\1}/'		\
		-e 's/^ File : \(.*\)/\\File {\1}/'
