build.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. set -e
  3. # Fixes pandoc mangling emojis
  4. export LANG=C.UTF-8
  5. inputs="behavior modeling vocabulary"
  6. git_branch=`git rev-parse --abbrev-ref HEAD`
  7. git_commit_id=`git rev-parse HEAD`
  8. git_commit_id_short=`git rev-parse --short HEAD`
  9. now=`date --utc +%Y-%m-%d`
  10. dirty () {
  11. git diff-index --quiet HEAD --
  12. }
  13. runPandoc () {
  14. local dir="$1"
  15. local file="$2"
  16. if [ "$3" == "true" ]; then
  17. local toc="--table-of-contents --number-sections"
  18. else
  19. local toc=""
  20. fi
  21. local output="html/$file.html"
  22. local suffix=".html"
  23. pandoc $dir/$file.md \
  24. --from markdown \
  25. --to html \
  26. --template html/template.html \
  27. $toc \
  28. --variable "gitbranch:$git_branch" \
  29. --variable "gitcommitid:$git_commit_id" \
  30. --variable "gitcommitidshort:$git_commit_id_short" \
  31. --variable "date:$now" \
  32. --variable "other-theme:$otherTheme" \
  33. --variable "suffix:$suffix" \
  34. --output "$output"
  35. #$gitdirty \
  36. }
  37. render () {
  38. local dir="$1"
  39. local file="$2"
  40. local toc="$3"
  41. runPandoc $dir $file $toc
  42. }
  43. #dirty
  44. #if [ $? -eq 0 ]; then
  45. # gitdirty=""
  46. #else
  47. # gitdirty="--variable gitdirty"
  48. #fi
  49. cp rdf/context.jsonld html/ns
  50. render html index "false"
  51. render html funding-plan "false"
  52. for file in $inputs; do
  53. render spec $file "true"
  54. done