From 741d4e0505c588f38a64350c1d3c53c74f7ac22c Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 9 Jun 2016 14:22:22 +0200 Subject: documentation: switch to pandoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I60fcea9d370f5b98efa1e08632f5f9682741b8c1 Signed-off-by: José Bollo --- doc/updt.sh | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'doc/updt.sh') 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=' - - - - - -GENERATED-MARKDOWN-HERE - -' - -# 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 -- cgit 1.2.3-korg