summaryrefslogtreecommitdiff
path: root/Makefile
blob: 53825dc6b262e2ba62ae0b210960f05c9de0d376 (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. # To produce final document: make -B STATUS=final
  12. STATUS ?= draft
  13. args += --template=template.tex --latex-engine=xelatex
  14. args += -H header.tex -B before.tex -A after.tex
  15. args += $(filters:%=--filter %)
  16. args += $(PANDOC_CITEPROC_FILE:%=--bibliography=%)
  17. args += -V mainfont="Lora" -V sansfont="Quattrocento Sans" -V monofont="Inconsolata"
  18. args += -V documentclass=memoir -V headstyles=komalike -V chapterstyle=ell
  19. args += -V classoption=titlepage -V classoption=$(STATUS)
  20. args += -V lang=english -V langoption=variant=british
  21. args += -V title="Ensuring utmost transparency"
  22. args += -V subtitle="Free Software and Open Standards under the Rules of Procedure of the European Parliament"
  23. args += -V author="Carlo Piana" -V author="Ulf Öberg"
  24. args += -V date=""
  25. flavors = a4 book ebook
  26. args_a4 = $(args) -V papersize=a4paper -V fontsize=10pt -V classoption=oneside
  27. args_book = $(args) -V papersize=b5paper -V fontsize=10pt -V classoption=twoside
  28. args_ebook = $(args) -V papersize=ebook -V fontsize=12pt -V classoption=oneside
  29. all: $(flavors:%=$(stem)-%.pdf)
  30. download:
  31. wget -o $(stem).raw '$(source_baseurl)index.php?title=$(source_basename)&action=edit'
  32. $(stem).mediawiki: $(stem).raw
  33. perl -0777 -MHTML::Entities -MURI::Escape -p \
  34. -e 's|.*<textarea[^>]*>||s; s|</textarea.*||s;' \
  35. -e 'decode_entities($$_);' \
  36. -e 's|.*?\n= |= |s;' \
  37. -e 's|<!--.*-->||s;' \
  38. -e '$(re_blockquote);' \
  39. -e '$(re_urlencode);' \
  40. < $< > $@
  41. $(flavors:%=$(stem)-%.pdf): $(stem)-%.pdf: $(stem).mediawiki $(templates) $(filters)
  42. pandoc -f mediawiki $(args_$*) -o $@ $<