On Wed, Jun 18, 2014 at 10:48:51AM +0200, Bernd Warken wrote:
> > No, I am not (yet?) a groff contributer. But I could publish my script, if 
> > there is general interest.
> 
> Please publish your script!  The implementation in `grog' would be very easy. 
>  But `groff.cpp'
> needs C++, which is still quite hard.
> 
> It would be useful as well, if the `tmac' name is included as well: man, 
> mdoc, me, mm, me, mom, etc.
> For it is often hard to discover with `grog' and `groffer' which `tmac' 
> should be there, e.g. the
> difference of `man' and `ms'.
> 
It is attached and might need some adjustments according to individual needs.

Some comments:

The default macro package is mm, man and mom are also supported.

The script "addtbl" adds numerical entries of specified table colums and
writes new table lines containing the respective sum. 

The script "squezetbl" eliminates leading and trailing blanks from table entries

Have fun,

    ulrich
#! /bin/bash

[ $# = 0 ] && {
  echo usage: $0 [ -f out ] file
  exit
}

PRE=
OPTS=
OUT=
PDF=
MAC=mm
while [ $# != 0 ]
do 
  case "$1" in
    -f) shift
        OUT=$1
        ;;
  -man) MAC=man
        ;;
    -l) # landscape
        FORM=lnd
        ;;
  -pdf) PDF=1
        ;;
     *) FILE="$1"
        # check for .\" eqn tbl add lnd eng mom
        for i in `read x < $1; echo $x`
        do
          case $i in
          eqn) OPTS="$OPTS -e" ;;
          lnd) FORM=lnd ;;
          tbl) OPTS="$OPTS -t"
               PRE="$PRE | squezetbl "
               ;;
          add) PRE="$PRE | addtbl " ;;
          eng) longdash="\40-\40 \\\\(em" ;;
          mom) MAC=mom ;;
            *) :
          esac
        done
        ;;
  esac
  shift
done

case $FILE in
  *.mom) MAC=mom;
         BASE=${FILE%.mom} ;;
      *) BASE=$FILE
esac

[ "$OUT" = "" ] && OUT=${BASE}.ps

case "$MAC" in
  mom) SO="/home/privat/bin/defines.mom" ;;
  mm)  SO="/home/privat/bin/roffinit" 
       if [ "$FORM" = lnd ]
       then
         OPTS="$OPTS -r L=21.12c -r W=23.95c -r O=2.8c"
       else 
         OPTS="$OPTS -r L=29.00c -r W=15.75c -r O=2.5c"
       fi
       ;;
  *)
esac

OPTS="$OPTS -$MAC"

if [ "$FORM" = lnd ]
then
  OPTS="$OPTS -P-l -P-pa4"
else 
  OPTS="$OPTS -P-pa4"
fi


echo "{ cat $SO; cat $FILE $PRE
      } | groff -Tps -k $OPTS - > $OUT"
eval "{ cat $SO; cat $FILE $PRE
      } | groff -Tps -k $OPTS - > $OUT"

[ "$PDF" = 1 ] && ps2pdf $OUT $BASE.pdf
echo done

Reply via email to