booxdown 979 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. MDFILE=$1
  3. PDFFILE=$(basename $MDFILE .md).pdf
  4. FILE=$(mktemp XXXXXXXXXX-${MDFILE})
  5. HAS_METADATA=0
  6. if head -n 1 ${MDFILE} | grep -- '---' > /dev/null ; then
  7. echo "Metadata Block Found"
  8. HAS_METADATA=1
  9. fi
  10. cat <<EOF >> $FILE
  11. ---
  12. documentclass: scrartcl
  13. classoption:
  14. - DIV=14
  15. papersize: a5
  16. fontsize: 10pt
  17. mainfont: LucidaBrightOT
  18. mainFontOptions:
  19. - Numbers=OldStyle
  20. sansfont: LucidaSansOT
  21. mathFont: LucidaBrightMathOT
  22. monofont: IBMPlexMono
  23. monofontoptions:
  24. - Scale=MatchLowercase
  25. - StylisticSet=3
  26. csquotes: true
  27. highlight-style: monochrome
  28. citemethod: biblatex
  29. pdfa: true
  30. hyperrefoptions:
  31. - breaklinks=true
  32. - bookmarks=true
  33. EOF
  34. if [ $HAS_METADATA -eq 1 ] ; then
  35. cat $MDFILE | sed '1 d' >> $FILE
  36. else
  37. echo "..." >> $FILE
  38. cat $MDFILE >> $FILE
  39. fi
  40. echo "Processing file to PDF."
  41. pandoc -f markdown \
  42. -s -t pdf \
  43. --highlight-style monochrome \
  44. --pdf-engine='lualatex' \
  45. -o $PDFFILE \
  46. $FILE
  47. echo "Done."
  48. rm $FILE