From 9c54f354cec365e6f4bf8f297902694b20808c1d Mon Sep 17 00:00:00 2001 From: John Levon Date: Fri, 9 Aug 2002 15:42:45 +0000 Subject: [PATCH] try to force +x git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4926 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/TeXFiles.sh | 79 ++++++++++++++++ lib/scripts/convertDefault.sh | 10 ++ lib/scripts/lyxpreview2ppm.sh | 166 ++++++++++++++++++++++++++++++++++ lib/scripts/pic2png_eps.sh | 3 + 4 files changed, 258 insertions(+) create mode 100755 lib/scripts/TeXFiles.sh create mode 100644 lib/scripts/convertDefault.sh create mode 100644 lib/scripts/lyxpreview2ppm.sh create mode 100644 lib/scripts/pic2png_eps.sh diff --git a/lib/scripts/TeXFiles.sh b/lib/scripts/TeXFiles.sh new file mode 100755 index 0000000000..976c8749ac --- /dev/null +++ b/lib/scripts/TeXFiles.sh @@ -0,0 +1,79 @@ +#!/bin/sh +# file: ~/bin/TeXFiles.sh +# all files -> without option +# TeX class files -> option cls +# TeX style files -> option sty +# bibtex style files -> option bst +# +# with the help +# of kpsewhich and creates a +# bstFiles.lst, clsFiles.lst, styFiles.lst +# without any parameter all files are created. +# +# Herbert Voss +# +# Updates from Jean-Marc Lasgouttes. +# +CLS_STYLEFILE=clsFiles.lst +STY_STYLEFILE=styFiles.lst +BST_STYLEFILE=bstFiles.lst +version='$Id: TeXFiles.sh,v 0.2 2001-10-15' +progname=`echo $0 | sed 's%.*/%%'` +usage="Usage: TeXFiles.sh [-version | cls | sty | bst] + Default is without any Parameters, + so that all files will be created" + +types=$1 +test -z "$types" && types="cls sty bst" + +# +# MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use ';' to separate +# directories in path lists whereas Unixes uses ':'. +# $SEP holds the right character to be used by the scripts. +# +#??????????????? +# never used this one with windows and what happens with mac?? +#??????????????? +# +if test -z "$COMSPEC" && test -z "$ComSpec"; then SEP=':'; else SEP=';'; fi + +# +# A copy of some stuff from mktex.opt, so we can run in the presence of +# terminally damaged ls-R files. +# +if test "x$1" = x--help || test "x$1" = x-help; then + echo "$usage" + exit 0 +elif test "x$1" = x--version || test "x$1" = x-version; then + echo "`basename $0` $version" + kpsewhich --version + exit 0 +fi + +for type in $types ; do + echo "Indexing files of type $type" + case $type in + cls) outfile=$CLS_STYLEFILE + kpsetype=.tex;; + sty) outfile=$STY_STYLEFILE + kpsetype=.tex;; + bst) outfile=$BST_STYLEFILE + kpsetype=.bst;; + *) echo "ERROR: unknown type $type" + exit 1;; + esac + + rm -f $outfile + touch $outfile + + dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%///%/%' -e 's%//%/%g' -e 's%!!%%g'` + + for dir in $dirs ; do + find $dir -follow -name "*.$type" >>$outfile 2>/dev/null + done + +done +#echo "list saved in $STYLEFILE" +#echo `wc -l $CLS_STYLEFILE` # only for information +# +# this is the end my friends ... Jim Morrison and the Doors in "The End" diff --git a/lib/scripts/convertDefault.sh b/lib/scripts/convertDefault.sh new file mode 100644 index 0000000000..53bf117141 --- /dev/null +++ b/lib/scripts/convertDefault.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# this is the default converter if no one other was +# defined by the user in edit->preferences->converter +# +# the user can also redefine this default converter +# with an own shell script in ~/.lyx/scripts +# +# converts an image from $1 to $2 format +convert -depth 8 $1 $2 +exit 0 diff --git a/lib/scripts/lyxpreview2ppm.sh b/lib/scripts/lyxpreview2ppm.sh new file mode 100644 index 0000000000..2720b9bbb6 --- /dev/null +++ b/lib/scripts/lyxpreview2ppm.sh @@ -0,0 +1,166 @@ +#!/bin/sh +# +# \file lyxpreview2ppm.sh +# Copyright 2002 the LyX Team +# Read the file COPYING +# +# \author Angus Leeming, leeming@lyx.org +# +# with much help from David Kastrup, david.kastrup@t-online.de. +# The sed script was created with advice from Praveen D V, praveend@sasken.com +# and the sed users' list, sed-users@yahoogroups.com. + +# This script takes a LaTeX file and generates PPM files, one per page. +# The idea is to use it with preview.sty to create small bitmap previews of +# things like math equations. + +# The script takes two arguments, the name of the file to be converted and +# the resolution of the generated image, to be passed to gs. +if [ $# -ne 2 ]; then + exit 1 +fi + +# A couple of helper functions +FIND_IT () { + which ${EXECUTABLE} > /dev/null + STATUS=$? + if [ ${STATUS} -ne 0 ]; then + echo "Unable to find \"${EXECUTABLE}\". Please install." + exit 1 + fi +} + +BAIL_OUT () { + # Remove everything except the original .tex file. + FILES=`ls ${BASE}* | sed -e "/${BASE}.tex/d"` + rm -f ${FILES} texput.log + exit 1 +} + +# We use latex, dvips and gs, so check that they're all there. +EXECUTABLE=latex; FIND_IT +EXECUTABLE=dvips; FIND_IT +EXECUTABLE=gs; FIND_IT + +# Initialise some variables. +TEXFILE=`basename $1` +RESOLUTION=$2 + +DIR=`dirname $1` +BASE=`basename $1 .tex` +DVIFILE=${BASE}.dvi +PSFILE=${BASE}.ps +METRICSFILE=${BASE}.metrics + +# LaTeX -> DVI. +cd ${DIR} +latex ${TEXFILE} +STATUS=$? +if [ ${STATUS} -ne 0 ]; then + # LaTeX failed. + # preview.sty has known problems with the showlabels option, + # so remove it and try again. + # This "fix" should be removed once preview-latex 0.73 is released. + sed -e '/^\\usepackage/,/{preview}$/s/,showlabels//' \ + < ${TEXFILE} > .${TEXFILE} + cmp -s ${TEXFILE} .${TEXFILE} + STATUS=$? + if [ ${STATUS} -eq 0 ]; then + rm -f .${TEXFILE} + echo "Failed: latex ${TEXFILE}" + BAIL_OUT + fi + + mv -f .${TEXFILE} ${TEXFILE} + latex ${TEXFILE} + STATUS=$? + if [ ${STATUS} -ne 0 ]; then + echo "Failed: latex ${TEXFILE}" + BAIL_OUT + fi +fi + +# DVI -> PostScript +dvips -o ${PSFILE} ${DVIFILE} +STATUS=$? +if [ ${STATUS} -ne 0 ]; then + echo "Failed: dvips -o ${PSFILE} ${DVIFILE}" + BAIL_OUT +fi + +# PostScript -> Bitmap files +# Older versions of gs have problems with a large degree of anti-aliasing +# at high resolutions +ALPHA=4 +if [ ${RESOLUTION} -gt 150 ]; then + ALPHA=2 +fi + +gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnmraw -sOutputFile=${BASE}%03d.ppm \ + -dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} -r${RESOLUTION} \ + ${PSFILE} + +STATUS=$? +if [ ${STATUS} -ne 0 ]; then + echo "Failed: gs ${PSFILE}" + BAIL_OUT +fi + +# Attempt to generate a file ${METRICSFILE} that contains only the tightpage +# bounding box info, extract from ${PSFILE} + +# 1. Create a file containing the sed instructions +SEDFILE=${BASE}.sed +cat - > ${SEDFILE} < ${METRICSFILE} +rm -f ${SEDFILE} + +# The ppm files have spurious (?! say some !) white space on the left and right +# sides. If you want this removed set REMOVE_WS=1. +REMOVE_WS=0 + +which pnmcrop > /dev/null +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + REMOVE_WS=0 +fi + +if [ ${REMOVE_WS} -eq 1 ]; then + TMP=.${BASE}.ppm + for FILE in `ls ${BASE}???.ppm` + do + pnmcrop -left ${FILE} | pnmcrop -right > ${TMP} + STATUS=$? + if [ ${STATUS} -eq 0 ]; then + mv -f ${TMP} ${FILE} + fi + done +fi + +# All was successful, so remove everything except the ppm files and the +# metrics file. +FILES=`ls ${BASE}* | sed -e "/${BASE}.metrics/d" -e "/${BASE}[0-9]\{3\}.ppm/d"` +rm -f ${FILES} diff --git a/lib/scripts/pic2png_eps.sh b/lib/scripts/pic2png_eps.sh new file mode 100644 index 0000000000..7f59c10da0 --- /dev/null +++ b/lib/scripts/pic2png_eps.sh @@ -0,0 +1,3 @@ +#!/bin/sh +convert $1 $2.eps +convert $1 $2.png -- 2.39.5