A small, comfortable nook pertaining to technology, current events, astronomy, and sailing and navigation.

Showing posts with label Documentation. Show all posts
Showing posts with label Documentation. Show all posts

Thursday, February 14, 2008

Pretty-Print With Enscript

Here's how I obtain high-quality, syntax-colored prints (or PDFs) of my source code files:
#!/bin/bash

ENSCRIPT_OPTS="--fancy-header=emacs -H3 -j -f Courier7"
ENSCRIPT_OPTS="${ENSCRIPT_OPTS} --color -2 -r -E"
ENSCRIPT_OPTS="${ENSCRIPT_OPTS} --mark-wrapped-lines=arrow"
ENSCRIPT_OPTS="${ENSCRIPT_OPTS} --ul-position=+125-25"

if [ $# -lt 1 ]; then
echo "Usage: ..."
exit 1
fi

FILE=${1}

enscript ${ENSCRIPT_OPTS} ${FILE} -o ${FILE}.ps
Enscript knows about dozens of types of source for colorizing its output. Once I've created the Postscript output, I can either print it as it is, or generate a PDF file for a handy on-screen reference.