-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathmake-examples.sh
executable file
·56 lines (49 loc) · 1.42 KB
/
make-examples.sh
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
#!/bin/bash
for cowfile in ./cows/*.cow; do
cowname=$(basename $cowfile)
echo ""
echo "## ${cowname}"
cowname="${cowname%.*}"
imgname=""
#check if image file matching this cow name exists
FILE=converter/src_images/${cowname}.png
if test -f "$FILE"; then
imgname="$FILE"
fi
if [ -z "$imgname" ]; then #if cow doesn't have a png image related, then just print the cow normally
echo '```'
cowsay -f ${cowfile} "$cowname"
echo '```'
else # otherwise insert an image tag for the source image
echo "<img src=\"$imgname\" height=\"200\" />"
fi
echo ""
done
# Show true color cows separately
echo ""
echo "# True Color cows"
for cowfile in ./cows/true-color/*.cow; do
cowname=$(basename $cowfile)
echo ""
echo "## ${cowname}"
cowname="${cowname%.*}"
imgname=""
#check if image file matching this cow name exists
FILE="converter/src_images/${cowname}-tc.png"
if test -f "$FILE"; then
imgname="$FILE"
else # if image doesn't exist, check if one without the -tc suffix exists
FILE="converter/src_images/${cowname}.png"
if test -f "$FILE"; then
imgname="$FILE"
fi
fi
if [ -z "$imgname" ]; then #if cow doesn't have a png image related, then just print the cow normally
echo '```'
echo "COW NOT FOUND"
echo '```'
else # otherwise insert an image tag for the source image
echo "<img src=\"$imgname\" height=\"200\" />"
fi
echo ""
done