#!/bin/sh
# wrapper for texvc, in use with mediawiki
#
# it takes the input and splits it up,
# grouping the tex commands together
#
# This was created for making <math> support
# work with php safe_mode
#
# Created by Mattias Guns <tias@ulyssis.org>
# http://xylofaan.ulyssis.org/patch/mediawiki/math_safe_mode/

TEXVC="$PWD/math/texvc";
# texvc <temp directory> <output directory> <TeX code> <encoding>

WC=`echo "$*" | wc -w`
PARAMS=`echo "$*" | sed "s/ /\t/g"`

temp_dir=`echo "$PARAMS" | cut -f 1`
out_dir=`echo "$PARAMS" | cut -f 2`
encoding=`echo "$PARAMS" | cut -f $WC`
let "WC -= 1" # excl last one
tex_code=`echo "$PARAMS" | cut -f 3-$WC`
tex_code=`echo "$tex_code" | sed "s/\t/ /g"`

# need to indicate that $F are together (= latex code)
out=`$TEXVC "$temp_dir" "$out_dir" "$tex_code" "$encoding"`
echo -n "$out"
