stem = eut source_baseurl = http://euwiki.org/ source_basename = EUT/2nd-edition # work around in mediawiki bug parsing blockquote tags on same line re_blockquote = s|\n*()\n*|\n$$1\n|g # work around modest URL parsing re_urlencode = s|\bhttps?://$$RE{net}{domain}{-nospace}{-rfc1101}(?::\d+)?/\K(\S*?)(?=[.,;]?[\s<\"\|}])|uri_escape(uri_unescape($$1), "^A-Za-z0-9/\.")|eg templates = template.tex header.tex before.tex after.tex filters = ./pandoc-memoir ./pandoc-cs1 export PANDOC_CITEPROC_FILE = $(stem).bib filters += $(if $(PANDOC_CITEPROC_FILE),pandoc-citeproc) filters += ./pandoc-iri localfilters = $(filter ./%,$(filters)) # To produce final document: make -B STATUS=final STATUS ?= draft title = Ensuring utmost transparency subtitle = Free Software and Open Standards under the Rules of Procedure of the European Parliament args_filter += $(filters:%=--filter %) args_meta += $(PANDOC_CITEPROC_FILE:%=-M bibliography=%) args_meta += -V lang=english -V langoption=variant=british args_meta += -M title="$(title) - $(subtitle)" args_meta += -V title="$(title)" args_meta += -V subtitle="$(subtitle)" args_meta += -M author="Carlo Piana, Ulf Öberg" args_meta += -V author="Carlo Piana" -V author="Ulf Öberg" args_meta += -V date="" args_latex += --template=template.tex --latex-engine=xelatex args_latex += -H header.tex -B before.tex -A after.tex args_latex += -V mainfont="Lora" -V sansfont="Quattrocento Sans" -V monofont="Inconsolata" args_latex += -V documentclass=memoir -V headstyles=komalike -V chapterstyle=ell args_latex += -V classoption=titlepage -V classoption=$(STATUS) flavors = a4 book ebook args_a4 = -V papersize=a4paper -V fontsize=10pt -V classoption=oneside args_book = -V papersize=b5paper -V fontsize=10pt -V classoption=twoside args_ebook = -V papersize=ebook -V fontsize=12pt -V classoption=oneside all: $(flavors:%=$(stem)-%.pdf) download: wget -O $(stem).raw '$(source_baseurl)w/index.php?title=$(source_basename)&action=edit' $(stem).mediawiki: $(stem).raw perl -C -0777 -MHTML::Entities -MRegexp::Common=net -MURI::Escape -p \ -e 's|.*]*>||s; s|||s;' \ -e '$(re_blockquote);' \ -e '$(re_urlencode);' \ < $< > $@ $(stem).native: $(stem).mediawiki $(localfilters) pandoc -f mediawiki $(args_meta) $(args_filter) -o $@ $< $(flavors:%=$(stem)-%.pdf) $(stem).tex: $(stem).native $(templates) pandoc $(args_meta) $(args_latex) $(args_$(@:$(stem)-%.pdf=%)) -o $@ $<