-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtoc.sh
executable file
·32 lines (24 loc) · 1.1 KB
/
toc.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
#!/bin/bash
sep=$(echo -e ". \n")
function make_toc() {
fl=$(ls $1/*.md)
echo '<div class="twocolumns"><ol>'
head -q -n 1 $fl | cut -c 2- | paste -d ':' - <(echo "$fl") | sed -E 's#^.(.*)[:](.*)[.]md# [\1](/\2.html)#;s/^/<li>/;s#$#</li>#'
echo '</ol></div>'
}
if [ "$#" -gt '1' ]; then
echo -e "% $2\n"
make_toc "$1"
else
echo -e "% Django (anti)patterns\n"
echo -e '<h1 class="patterntype"><a href="/antipattern.html"><i class="fas fa-ban"></i> Antipatterns</a></h1>\n'
make_toc antipattern
echo -e '\n\n<h1 class="patterntype"><a href="/pattern.html"><i class="fas fa-shapes"></i> Patterns</a></h1>\n'
make_toc pattern
echo -e '\n\n<h1 class="patterntype"><a href="/difference-between.html"><i class="fas fa-adjust"></i> Difference between …</a></h1>\n'
make_toc difference-between
echo -e '\n\n<h1 class="patterntype"><a href="/troubleshooting.html"><i class="fas fa-bug"></i> Troubleshooting</a></h1>\n'
make_toc troubleshooting
echo -e '\n\n<h1 class="patterntype"><a href="/qa.html"><i class="fas fa-question"></i> QA</a></h1>\n'
make_toc qa
fi