publish.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2017 Alyssa Rosenzweig <alyssa@rosenzweig.io
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. echo $1
  18. FILE=${1%.md}
  19. cat $1 > temp.md
  20. if [ "${FILE}" != "./index" ]; then
  21. if [[ $FILE == *index ]]
  22. then
  23. DEST=".."
  24. else
  25. DEST="index.html"
  26. fi
  27. RETURN="<a href='$DEST'>Back to previous index</a>"
  28. fi
  29. echo "" >> temp.md
  30. echo "[License](/license.md)" >> temp.md
  31. # change out .md -> .html
  32. sed temp.md -i -e 's/\.md\(#[a-z\-]*\)*)/.html\1)/g'
  33. # work around issue #2872
  34. TOC=$(grep -q "^x-toc-enable: true$" temp.md && echo "--toc --toc-depth=2")
  35. # work around heterogenous pandoc versions
  36. SMART=$(pandoc -v | grep -q '2\.0' || echo "--smart")
  37. # chuck through pandoc
  38. pandoc $TOC $SMART temp.md -s --css /global.css -T Libreboot \
  39. --template template.html --metadata return="$RETURN"> $FILE.html