summaryrefslogtreecommitdiff
path: root/Makefile
blob: 07bd8def3d55755ef82123fa0c101f78a7db1c89 (plain)
  1. stem = eut
  2. source_baseurl = http://euwiki.org/
  3. source_basename = EUT/2nd-edition
  4. # work around in mediawiki bug parsing blockquote tags on same line
  5. re_blockquote = s|\n*(</?blockquote>)\n*|\n$$1\n|g
  6. # work around modest URL parsing <https://github.com/jgm/pandoc/issues/1838>
  7. re_urlencode = s|\bhttp[^\s\"]+?\K(--+)|uri_escape($$1, "-")|eg
  8. templates = template.tex header.tex before.tex after.tex
  9. filters = ./pandoc-filter-sections ./pandoc-filter-bib
  10. export PANDOC_CITEPROC_FILE = $(stem).bib
  11. #PANDOC_CITEPROC_FILE = $(stem).bib
  12. # To produce final document: make -B STATUS=final
  13. STATUS ?= draft
  14. args += --template=template.tex --latex-engine=xelatex
  15. args += -H header.tex -B before.tex -A after.tex
  16. args += $(filters:%=--filter %)
  17. args += $(PANDOC_CITEPROC_FILE:%=--bibliography=%)
  18. args += -V mainfont="Lora" -V sansfont="Quattrocento Sans" -V monofont="Inconsolata"
  19. args += -V papersize=a4paper -V fontsize=10pt
  20. args += -V documentclass=memoir -V headstyles=komalike -V chapterstyle=ell
  21. args += -V classoption=oneside -V classoption=titlepage -V classoption=$(STATUS)
  22. args += -V lang=english -V langoption=variant=british
  23. args += -V title="Ensuring utmost transparency"
  24. args += -V subtitle="Free Software and Open Standards under the Rules of Procedure of the European Parliament"
  25. args += -V author="Carlo Piana" -V author="Ulf Öberg"
  26. args += -V date=""
  27. all: $(stem).pdf
  28. download:
  29. wget -o $(stem).raw '$(source_baseurl)index.php?title=$(source_basename)&action=edit'
  30. $(stem).mediawiki: $(stem).raw
  31. perl -0777 -MHTML::Entities -MURI::Escape -p \
  32. -e 's|.*<textarea[^>]*>||s; s|</textarea.*||s;' \
  33. -e 'decode_entities($$_);' \
  34. -e 's|.*?\n= |= |s;' \
  35. -e 's|<!--.*-->||s;' \
  36. -e '$(re_blockquote);' \
  37. -e '$(re_urlencode);' \
  38. < $< > $@
  39. $(stem).pdf: $(stem).mediawiki $(templates) $(filters)
  40. pandoc -f mediawiki $(args) -o $@ $<