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