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