build.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 theme="$4"
  22. if [ "$theme" == "light" ]; then
  23. local otherTheme="/index/dark"
  24. local otherThemeName="🌑"
  25. local output="html/$file.html"
  26. local suffix=".html"
  27. else
  28. local otherTheme="/index"
  29. local otherThemeName="🌞"
  30. local output="html/$file/dark.html"
  31. local suffix="/dark.html"
  32. mkdir -p "html/$file"
  33. fi
  34. pandoc $dir/$file.md \
  35. --from markdown \
  36. --to html \
  37. --template html/template.html \
  38. $toc \
  39. --variable "gitbranch:$git_branch" \
  40. --variable "gitcommitid:$git_commit_id" \
  41. --variable "gitcommitidshort:$git_commit_id_short" \
  42. --variable "date:$now" \
  43. --variable "theme:$theme" \
  44. --variable "other-theme:$otherTheme" \
  45. --variable "other-theme-name:$otherThemeName" \
  46. --variable "suffix:$suffix" \
  47. --output "$output"
  48. #$gitdirty \
  49. }
  50. render () {
  51. local dir="$1"
  52. local file="$2"
  53. local toc="$3"
  54. runPandoc $dir $file $toc "light"
  55. runPandoc $dir $file $toc "dark"
  56. }
  57. #dirty
  58. #if [ $? -eq 0 ]; then
  59. # gitdirty=""
  60. #else
  61. # gitdirty="--variable gitdirty"
  62. #fi
  63. cp rdf/context.jsonld html/ns
  64. render html index "false"
  65. render html funding-plan "false"
  66. for file in $inputs; do
  67. render spec $file "true"
  68. done