summaryrefslogtreecommitdiff
path: root/Makefile
blob: 605989683636e29a7aa16d3aa4b5da04c91e6556 (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 ./pandoc-filter-iri
  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 documentclass=memoir -V headstyles=komalike -V chapterstyle=ell
  20. args += -V classoption=titlepage -V classoption=$(STATUS)
  21. args += -V lang=english -V langoption=variant=british
  22. args += -V title="Ensuring utmost transparency"
  23. args += -V subtitle="Free Software and Open Standards under the Rules of Procedure of the European Parliament"
  24. args += -V author="Carlo Piana" -V author="Ulf Öberg"
  25. args += -V date=""
  26. flavors = a4 book ebook
  27. args_a4 = $(args) -V papersize=a4paper -V fontsize=10pt -V classoption=oneside
  28. args_book = $(args) -V papersize=b5paper -V fontsize=10pt -V classoption=twoside
  29. args_ebook = $(args) -V papersize=ebook -V fontsize=12pt -V classoption=oneside
  30. all: $(flavors:%=$(stem)-%.pdf)
  31. download:
  32. wget -o $(stem).raw '$(source_baseurl)index.php?title=$(source_basename)&action=edit'
  33. $(stem).mediawiki: $(stem).raw
  34. perl -0777 -MHTML::Entities -MURI::Escape -p \
  35. -e 's|.*<textarea[^>]*>||s; s|</textarea.*||s;' \
  36. -e 'decode_entities($$_);' \
  37. -e 's|.*?\n= |= |s;' \
  38. -e 's|<!--.*-->||s;' \
  39. -e '$(re_blockquote);' \
  40. -e '$(re_urlencode);' \
  41. < $< > $@
  42. $(flavors:%=$(stem)-%.pdf): $(stem)-%.pdf: $(stem).mediawiki $(templates) $(filters)
  43. pandoc -f mediawiki $(args_$*) -o $@ $<