X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=doc%2Fupdt.sh;fp=doc%2Fupdt.sh;h=e6b721d612761a0c5c92a4031b831e297d02bede;hb=741d4e0505c588f38a64350c1d3c53c74f7ac22c;hp=1c9d023eb75b3af7375afee5aa3e3fa049937dca;hpb=16ac46f9966c85f5d8c3b766efb8df1417aa5ce2;p=src%2Fapp-framework-binder.git 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