summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2cbd7c8c052d1032199f9db1a67fe949045c7cad (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_filter += $(filters:%=--filter %)
  14. args_filter += $(PANDOC_CITEPROC_FILE:%=--bibliography=%)
  15. args_meta += -V lang=english -V langoption=variant=british
  16. args_meta += -V title="Ensuring utmost transparency"
  17. args_meta += -V subtitle="Free Software and Open Standards under the Rules of Procedure of the European Parliament"
  18. args_meta += -V author="Carlo Piana" -V author="Ulf Öberg"
  19. args_meta += -V date=""
  20. args_latex += --template=template.tex --latex-engine=xelatex
  21. args_latex += -H header.tex -B before.tex -A after.tex
  22. args_latex += -V mainfont="Lora" -V sansfont="Quattrocento Sans" -V monofont="Inconsolata"
  23. args_latex += -V documentclass=memoir -V headstyles=komalike -V chapterstyle=ell
  24. args_latex += -V classoption=titlepage -V classoption=$(STATUS)
  25. flavors = a4 book ebook
  26. args_a4 = -V papersize=a4paper -V fontsize=10pt -V classoption=oneside
  27. args_book = -V papersize=b5paper -V fontsize=10pt -V classoption=twoside
  28. args_ebook = -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. $(stem).native: $(stem).mediawiki $(filters)
  42. pandoc -f mediawiki $(args_filter) -o $@ $<
  43. $(flavors:%=$(stem)-%.pdf) $(stem).tex: $(stem).native $(templates)
  44. pandoc $(args_meta) $(args_latex) $(args_$(@:$(stem)-%.pdf=%)) -o $@ $<