Makefile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. OUT_DIR=output
  2. IN_DIR=markdown
  3. STYLES_DIR=styles
  4. STYLE=chmduquesne
  5. all: html pdf docx rtf
  6. pdf: init
  7. for f in $(IN_DIR)/*.md; do \
  8. FILE_NAME=`basename $$f | sed 's/.md//g'`; \
  9. echo $$FILE_NAME.pdf; \
  10. pandoc --standalone --template $(STYLES_DIR)/$(STYLE).tex \
  11. --from markdown --to context \
  12. --variable papersize=A4 \
  13. --output $(OUT_DIR)/$$FILE_NAME.tex $$f > /dev/null; \
  14. mtxrun --path=$(OUT_DIR) --result=$$FILE_NAME.pdf --script context $$FILE_NAME.tex > $(OUT_DIR)/context_$$FILE_NAME.log 2>&1; \
  15. done
  16. html: init
  17. for f in $(IN_DIR)/*.md; do \
  18. FILE_NAME=`basename $$f | sed 's/.md//g'`; \
  19. echo $$FILE_NAME.html; \
  20. pandoc --standalone --include-in-header $(STYLES_DIR)/$(STYLE).css \
  21. --lua-filter=pdc-links-target-blank.lua \
  22. --from markdown --to html \
  23. --output $(OUT_DIR)/$$FILE_NAME.html $$f \
  24. --metadata pagetitle=$$FILE_NAME;\
  25. done
  26. docx: init
  27. for f in $(IN_DIR)/*.md; do \
  28. FILE_NAME=`basename $$f | sed 's/.md//g'`; \
  29. echo $$FILE_NAME.docx; \
  30. pandoc --standalone $$SMART $$f --output $(OUT_DIR)/$$FILE_NAME.docx; \
  31. done
  32. rtf: init
  33. for f in $(IN_DIR)/*.md; do \
  34. FILE_NAME=`basename $$f | sed 's/.md//g'`; \
  35. echo $$FILE_NAME.rtf; \
  36. pandoc --standalone $$SMART $$f --output $(OUT_DIR)/$$FILE_NAME.rtf; \
  37. done
  38. init: dir version
  39. dir:
  40. mkdir -p $(OUT_DIR)
  41. version:
  42. PANDOC_VERSION=`pandoc --version | head -1 | cut -d' ' -f2 | cut -d'.' -f1`; \
  43. if [ "$$PANDOC_VERSION" -eq "2" ]; then \
  44. SMART=-smart; \
  45. else \
  46. SMART=--smart; \
  47. fi \
  48. clean:
  49. rm -f $(OUT_DIR)/*