Mercurial > hg > easyhg
annotate help/generate.sh @ 603:10ef94e51f44
Make sure we update the view after a failed merge
author | Chris Cannam |
---|---|
date | Tue, 03 Jul 2012 10:08:44 +0100 |
parents | 21aa41b62c3a |
children |
rev | line source |
---|---|
Chris@494 | 1 #!/bin/bash |
Chris@494 | 2 |
Chris@494 | 3 css='<link rel="stylesheet" type="text/css" href="help.css"/>' |
Chris@494 | 4 |
Chris@494 | 5 echo "$css" > topics.html |
Chris@494 | 6 cat intro.html >> topics.html |
Chris@494 | 7 |
Chris@494 | 8 pcat="" |
Chris@494 | 9 |
Chris@494 | 10 for x in topics/*.txt ; do |
Chris@494 | 11 |
Chris@494 | 12 b=`basename "$x" .txt` |
Chris@494 | 13 out="a-$b.html" |
Chris@494 | 14 |
Chris@494 | 15 echo "$css" > "$out" |
Chris@494 | 16 |
Chris@494 | 17 cat "$x" | perl -e ' |
Chris@494 | 18 $_ = join "", <>; |
Chris@494 | 19 s/^{[\w\s]+}//s; |
Chris@494 | 20 s/^(\s*)([A-Za-z][^\n]*)/$1<h2>$2<\/h2>/s; |
Chris@494 | 21 s/^\s+\*\s+(.*)$/<ul><li>$1<\/li><\/ul>/gm; |
Chris@496 | 22 s/\*([\w"][^\*]+)\*/<b>$1<\/b>/gs; |
Chris@494 | 23 s/"([\w])/“$1/gs; |
Chris@494 | 24 s/([\w])"/$1”/gs; |
Chris@495 | 25 s/^\#([^\s]+)$/<center><img src="images\/$1.png"><\/center>/gm; |
Chris@494 | 26 s/\n-+\n/\n/gs; |
Chris@494 | 27 s/\n\n([^\n])/\n\n<p>$1/gs; |
Chris@494 | 28 s/^\n*([^<\n])/\n<p>$1/gs; |
Chris@494 | 29 s/^\n*(<[^p])/\n<p>$1/gs; |
Chris@494 | 30 s/([^\n])\n\n/$1<\/p>\n\n/gs; |
Chris@494 | 31 s/([^>\n])\n*$/$1<\/p>\n\n/gs; |
Chris@496 | 32 s/\[\[([^\|]*)\|([^\]]*)\]\]/<a href="a-$1.html">$2<\/a>/gs; |
Chris@494 | 33 s/\[\[([^\|\]]*)\]\]/<a href="$1">$1<\/a>/gs; |
Chris@494 | 34 s/\b_([^_]+)_\b/<i>$1<\/i>/gs; |
Chris@494 | 35 s/@(\w[^@]+)@/<code>$1<\/code>/gs; |
Chris@494 | 36 s/---/—/gs; |
Chris@494 | 37 s/--/–/gs; |
Chris@494 | 38 s/<p><h2>/<h2>/gs; |
Chris@494 | 39 s/<\/h2><\/p>/<\/h2>/gs; |
Chris@494 | 40 print; |
Chris@494 | 41 ' >> "$out" |
Chris@494 | 42 |
Chris@494 | 43 category=`grep '^{.*}$' "$x" | sed 's/[{}]//g'` |
Chris@494 | 44 |
Chris@494 | 45 if [ "$category" != "$pcat" ]; then |
Chris@494 | 46 echo "<h3>$category</h3>" >> topics.html |
Chris@495 | 47 pcat="$category" |
Chris@494 | 48 fi |
Chris@494 | 49 |
Chris@494 | 50 grep '<h2>' "$out" | sed "s|<h2>|<p><a href=\"$out\">|" | sed 's/<\/h2>/<\/a><\/p>/' >> topics.html |
Chris@494 | 51 |
Chris@494 | 52 done |
Chris@494 | 53 |