7 # Author: Clemens Kraus (http://www.clemens-kraus.de)
13 # Unpack vym-file, only if it is one
15 echo $VYMFILE_EXT | grep -F ".vym" 1>/dev/null
18 echo ">> Unpacking files ..."
19 unzip $VYMFILE_EXT -d $VYMFILE_PATH 1>/dev/null
20 if [ $? -gt 0 ] ; then
21 echo ">>> Error in unzip! Aborting."
29 # change all txt-files into xml-format
31 for i in `ls $VYMFILE-note-*.txt 2>/dev/null`
33 # Check whether already modified
34 grep "<note>" $i 1>/dev/null
36 if [ $? -gt 0 ] ; then
37 echo ">> Modifying: "$i
38 # Each line gets an additional <line>-tag, because of the indents!
39 sed -e 's,^,<line><![CDATA[,g' -e 's,$,]]>\
</line>,g' $i > $i"_tmp"
42 echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" > $i
44 #echo "<![CDATA[" >> $i
57 echo ">> Starting XSLT transformation ..."
58 # sabcmd vym2html.xsl $VYMFILE".xml" \$filenamep=$VYMFILE \$wikistylep=$WIKISTYLEP \$genimagep=$GENIMAGEP \$stylesheetp=$STYLESHEETP > $VYMFILE".html"
59 xsltproc -o $VYMFILE".txt" --stringparam filenamep `pwd`/"$VYMFILE" `dirname $STYLESHEETP`/vym2txt.xsl $VYMFILE".xml"
61 if [ $? -gt 0 ] ; then
62 echo ">>> Error in xsltproc! Aborting."
69 # remove all temporary unpacked vym-files
71 echo $VYMFILE_EXT | grep -F ".vym" 1>/dev/null
74 echo ">> Removing temporary files ..."
75 for i in `ls $VYMFILE-note-*.txt 2>/dev/null`
80 for i in `ls $VYMFILE-image-*.* 2>/dev/null`
85 rm $VYMFILE".xml" 2>/dev/null
89 # -------------------- Parameter check -----------------------
92 USAGE="USAGE:\t`basename $0` vymfile.[vym|xml] -sp=\077 [Options]\n"
93 USAGE=$USAGE"\t-sp=\077: absolute stylesheet path (including name of stylesheet)\n"
94 USAGE=$USAGE"Output:\tvymfile.txt\n\n"
95 USAGE=$USAGE"Options:\n"
96 USAGE=$USAGE"-v: prints the version of vym2txt\n"
98 if [ "$1" = '-v' ]; then
99 echo "vym2txt Version: "$VERSION
102 if [ $# -lt 1 -o $# -gt 2 -o "$1" = '-help' ]; then
107 VYMFILE=`echo $VYMFILE_EXT | cut -d. -f1`
108 VYMFILE_PATH=`dirname $VYMFILE_EXT`
113 if [ ${arg:0:3} = '-sp' ]; then # take first 3 chars
114 STYLESHEETP=`echo $arg | cut -d= -f2`
115 elif [ "$arg" = '-help' ]; then
125 # ---------------------- Los geht's --------------------------
126 echo ">> Processing file '$VYMFILE_EXT' ..."
140 echo ">> ---------------------"