Mercurial > hg > easyhg
comparison help/generate.sh @ 494:41a156d439d0
Start adding Help
author | Chris Cannam |
---|---|
date | Thu, 18 Aug 2011 16:37:27 +0100 |
parents | |
children | e6141a238811 |
comparison
equal
deleted
inserted
replaced
493:75ebcacd3f75 | 494:41a156d439d0 |
---|---|
1 #!/bin/bash | |
2 | |
3 css='<link rel="stylesheet" type="text/css" href="help.css"/>' | |
4 backlink='<p><a href="topics.html">Back to Topics</a></p>' | |
5 | |
6 echo "$css" > topics.html | |
7 cat intro.html >> topics.html | |
8 | |
9 pcat="" | |
10 | |
11 for x in topics/*.txt ; do | |
12 | |
13 b=`basename "$x" .txt` | |
14 out="a-$b.html" | |
15 | |
16 echo "$css" > "$out" | |
17 echo "$backlink<hr>" >> "$out" | |
18 | |
19 cat "$x" | perl -e ' | |
20 $_ = join "", <>; | |
21 s/^{[\w\s]+}//s; | |
22 s/^(\s*)([A-Za-z][^\n]*)/$1<h2>$2<\/h2>/s; | |
23 s/^\s+\*\s+(.*)$/<ul><li>$1<\/li><\/ul>/gm; | |
24 s/"([\w])/“$1/gs; | |
25 s/([\w])"/$1”/gs; | |
26 s/^\#([^\s]+)$/<center><img src="images\/$1"><\/center>/gm; | |
27 s/\n-+\n/\n/gs; | |
28 s/\n\n([^\n])/\n\n<p>$1/gs; | |
29 s/^\n*([^<\n])/\n<p>$1/gs; | |
30 s/^\n*(<[^p])/\n<p>$1/gs; | |
31 s/([^\n])\n\n/$1<\/p>\n\n/gs; | |
32 s/([^>\n])\n*$/$1<\/p>\n\n/gs; | |
33 s/\[\[([^\|]*)\|([^\]]*)\]\]/<a href="$1">$2<\/a>/gs; | |
34 s/\[\[([^\|\]]*)\]\]/<a href="$1">$1<\/a>/gs; | |
35 s/\b_([^_]+)_\b/<i>$1<\/i>/gs; | |
36 s/\*(\w[^\*]+)\*/<b>$1<\/b>/gs; | |
37 s/@(\w[^@]+)@/<code>$1<\/code>/gs; | |
38 s/---/—/gs; | |
39 s/--/–/gs; | |
40 s/<p><h2>/<h2>/gs; | |
41 s/<\/h2><\/p>/<\/h2>/gs; | |
42 print; | |
43 ' >> "$out" | |
44 | |
45 echo "<hr>$backlink" >> "$out" | |
46 | |
47 category=`grep '^{.*}$' "$x" | sed 's/[{}]//g'` | |
48 | |
49 if [ "$category" != "$pcat" ]; then | |
50 echo "<h3>$category</h3>" >> topics.html | |
51 fi | |
52 | |
53 grep '<h2>' "$out" | sed "s|<h2>|<p><a href=\"$out\">|" | sed 's/<\/h2>/<\/a><\/p>/' >> topics.html | |
54 | |
55 done | |
56 |