-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_pdf
executable file
·57 lines (44 loc) · 1.46 KB
/
make_pdf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# make_pdf
# By: Russ Spivey
# require specific inputs...
if [[ $BASH_ARGC != "2" ]]; then
echo "Usage: make_pdf [dir] [syntax]"
echo " Where [dir] is the relative project directory"
echo " and [syntax] is either 'ruby' or 'bash'."
echo "Note: Must be run from the root of the git repo in which [dir] resides"
echo "Note: [dir] must contain readme.md and output.txt"
exit 1
fi
dir=$1
syntax=$2
# determine file extension from syntax
if [[ $syntax == 'ruby' ]]; then
extension="rb"
else
extension="sh"
fi
# get git log in reverse order with unified diffs
git log --reverse --oneline -p -- $dir > git_changelog.txt
# convert git history to .ps
enscript git_changelog.txt --highlight=diffu --output=git_changelog.ps --color --language=PostScript
# convert project files to .ps
enscript $dir/*.$extension --color --highlight=$syntax --output=project_files.ps --language=PostScript
# convert readme to html
markdown $dir/readme.md > readme.html
# convert readme to .ps
htmldoc -t ps --no-toc --no-title --no-numbered --footer ... readme.html > readme.ps
# convert output to .ps
enscript $dir/output.txt --output=output.ps --language=PostScript
# concatenate ps files together
./psjoin readme.ps project_files.ps output.ps git_changelog.ps > complete.ps
# convert .ps to .pdf
ps2pdf complete.ps $dir.pdf
# delete tmp files
rm git_changelog.txt
rm git_changelog.ps
rm project_files.ps
rm readme.ps
rm output.ps
rm complete.ps
rm readme.html