summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--before.tex20
-rwxr-xr-xmediawiki-matter29
3 files changed, 58 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 00dbe62..b8606d2 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,10 @@ filters = ./pandoc-cs1 ./pandoc-todo
filters += $(if $(citeproc_file),pandoc-citeproc)
filters += ./pandoc-iri
+mediawiki_includes = copyright.mw preface.mw foreword.mw
+
+includes += $(mediawiki_includes:.mw=.tex)
+
localfilters = $(filter ./%,$(filters))
title = Ensuring utmost transparency
@@ -48,11 +52,15 @@ $(stem).mw: $(stem).raw
./mediawiki-trim $@
./mediawiki-blockquote $@
./mediawiki-uri-escape $@
+ ./mediawiki-matter $@
$(stem).native: $(stem).mw $(localfilters)
$(env_filter) pandoc -f mediawiki $(args_meta) $(args_filter) -o $@ $<
-$(flavors:%=$(stem)-%.tex): $(stem)-%.tex: $(stem).native $(templates)
+$(mediawiki_includes:.mw=.tex): %.tex: %.mw $(stem).mw
+ pandoc -f mediawiki -t latex --chapters -o $@ $<
+
+$(flavors:%=$(stem)-%.tex): $(stem)-%.tex: $(stem).native $(templates) $(includes)
pandoc $(args_meta) $(args_latex) $(args_$*) -o $@ $<
XELATEX = xelatex -no-shell-escape -halt-on-error -interaction=batchmode
diff --git a/before.tex b/before.tex
index 5bfcd08..d790add 100644
--- a/before.tex
+++ b/before.tex
@@ -3,3 +3,23 @@
\hyphenpenalty=3500
\doublehyphendemerits=100000
\finalhyphendemerits=50000000
+
+\cleartoverso
+
+\begingroup
+\footnotesize
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{\baselineskip}
+\include{copyright}
+\endgroup
+
+{
+ \hypersetup{linkcolor=black}
+ \setcounter{tocdepth}{3}
+ \cleartorecto
+ \tableofcontents
+}
+
+\include{foreword}
+
+\include{preface}
diff --git a/mediawiki-matter b/mediawiki-matter
new file mode 100755
index 0000000..584e5f4
--- /dev/null
+++ b/mediawiki-matter
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+# separate frontmatter pieces from mainmatter
+
+use warnings;
+use strict;
+
+use Path::Tiny;
+use HTML::HTML5::Entities;
+
+my $infile = shift;
+my $outfile = shift || $infile;
+
+$_ = path($infile)->slurp_utf8;
+
+s|^((?:.*?\n)?)(= Preface(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
+path('preface.mw')->spew_utf8($2);
+
+s|^((?:.*?\n)?)(= Foreword(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
+path('foreword.mw')->spew_utf8($2);
+
+s|^((?:.*?\n)?)(= Copyright(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
+path('copyright.mw')->spew_utf8($2);
+
+s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
+
+path($outfile)->spew_utf8($_);
+
+1;