aboutsummaryrefslogtreecommitdiffstats
path: root/doc/updt.sh
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-06-09 14:22:22 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-06-09 14:22:22 +0200
commit741d4e0505c588f38a64350c1d3c53c74f7ac22c (patch)
treec5dcbc33bb759d0af7ed44c7b73317b3d7371e1b /doc/updt.sh
parent16ac46f9966c85f5d8c3b766efb8df1417aa5ce2 (diff)
documentation: switch to pandoc
Change-Id: I60fcea9d370f5b98efa1e08632f5f9682741b8c1 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'doc/updt.sh')
-rwxr-xr-xdoc/updt.sh34
1 files changed, 12 insertions, 22 deletions
diff --git a/doc/updt.sh b/doc/updt.sh
index 1c9d023e..e6b721d6 100755
--- a/doc/updt.sh
+++ b/doc/updt.sh
@@ -1,19 +1,15 @@
#!/bin/bash
-# the HTML template
-main='<html>
-<head>
- <link rel="stylesheet" type="text/css" href="doc.css">
- <meta charset="UTF-8">
-</head>
-<body>
-GENERATED-MARKDOWN-HERE
-</body>
-</html>'
-
-# substitute the pattern $1 by the content of the file $2
-subst() {
- awk -v pat="$1" -v rep="$(sed 's:\\:\\\\:g' $2)" '{gsub(pat,rep);gsub(pat,"\\&");print}'
+meta() {
+ awk '
+ NR == 1 { t = $0; next }
+ NR == 2 && $1 ~ "======" { next }
+ NR == 2 { exit }
+ $1 == "Date:" { d = $2; for(i = 3 ; i <= NF ; i++) d = d " " $i; next }
+ $1 == "Author:" { a = $2; for(i = 3 ; i <= NF ; i++) a = a " " $i; next }
+ $1 == "version" || $1 == "Version" {next}
+ /^[ \t]*$/ { printf "%% %s\n%% %s\n%% %s\n", t, a, d; exit }
+ ' "$1"
}
# update the date field of file $1
@@ -29,14 +25,8 @@ updadate() {
mkhtml() {
local x=$1
local h=${x%%.md}.html
- expand -i $x | sed 's:^ : :' > $h.pre
- markdown -f toc,autolink $h.pre > $h.toc.no
- markdown -Tf toc,autolink $h.pre > $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.*
+ { meta "$x"; sed 's/TABLE-OF-CONTENT-HERE//' "$x"; } |
+ pandoc --css doc.css -f markdown -t html5 --toc > "$h"
}
# apply