build.sh 1.7 KB

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