# Takes a local man page and makes a text, pdf and html version of it.
# If no file name given, uses SkantiControl.1
# Formats the output for a 80 columns screen
# Usage: makemanuals [<man page file>]
# Output: Manual-it.txt, Manual-it.pdf and Manual-it.html.
# I1EPJ 2021

#!/bin/bash

if test "$1" = ""; then
    MANNAME="RA3701Control.1"
else
    MANNAME=$1
fi

echo Making text, pdf and html versions of $MANNAME man page...

echo Writing Manual-it.txt...
export COLUMNS=80; man -l ../man/it/$MANNAME | col -b -x > ../doc/Manual-it.txt
# Get rid of extra spaces around punctuation
sed -i 's/ \. /\. /g' ../doc/Manual-it.txt
sed -i 's/ \.$/\./g' ../doc/Manual-it.txt
sed -i 's/\.   C/ \.   C/g' ../doc/Manual-it.txt
sed -i 's/ , /\, /g' ../doc/Manual-it.txt

echo Writing Manual-it.pdf...
export COLUMNS=80; man -t -l ../man/it/$MANNAME | ps2pdf - ../doc/Manual-it.pdf

echo Writing Manual-it.html...
export COLUMNS=80; man -l -Thtml ../man/it/$MANNAME > ../doc/Manual-it.html

echo Done!
