From 3eb8cb8867f083047c277527e83692cfaa479613 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 4 Jan 2015 12:50:17 +0100 Subject: Split and reorganize frontmatter. --- Makefile | 10 +++++++++- before.tex | 20 ++++++++++++++++++++ mediawiki-matter | 29 +++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 mediawiki-matter 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; -- cgit v1.2.3