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