aboutsummaryrefslogtreecommitdiffstats
path: root/doc/updt.sh
diff options
context:
space:
mode:
Diffstat (limited to 'doc/updt.sh')
-rwxr-xr-xdoc/updt.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/updt.sh b/doc/updt.sh
new file mode 100755
index 00000000..cd978e22
--- /dev/null
+++ b/doc/updt.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+subst() {
+ awk -v pat="$1" -v rep="$(sed 's:\\:\\\\:g' $2)" '{gsub(pat,rep);gsub(pat,"\\&");print}'
+}
+
+main='<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="doc.css">
+ <meta charset="UTF-8">
+</head>
+<body>
+GENERATED-MARKDOWN-HERE
+</body>
+</html>'
+
+for x in *.md; do
+ t=$(git log -n 1 --format=%ct $x)
+ [[ -n "$t" ]] || t=$(stat -c %Y $x)
+ d=$(LANG= date -d @$t +"%d %B %Y")
+ sed -i "s/^\( Date: *\).*/\1$d/" $x
+ h=${x%%.md}.html
+ markdown -f toc,autolink $x > $h.toc.no
+ markdown -Tf toc,autolink $x > $h.toc.yes
+ head --bytes=-$(stat -c %s $h.toc.no) $h.toc.yes > $h.toc
+ echo "$main" |
+ subst GENERATED-MARKDOWN-HERE $h.toc.no |
+ subst TABLE-OF-CONTENT-HERE $h.toc > $h
+# rm $h.toc*
+done
+