summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--before.tex11
-rwxr-xr-xmediawiki-matter12
-rwxr-xr-xpandoc-memoir26
4 files changed, 22 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 0d610f1..34bed6b 100644
--- a/Makefile
+++ b/Makefile
@@ -9,15 +9,13 @@ citeproc_file = $(stem).bib
templates = template.tex header.tex before.tex after.tex
-filters = ./pandoc-cs1 ./pandoc-todo
+filters = ./pandoc-memoir ./pandoc-cs1 ./pandoc-todo
filters += $(if $(citeproc_file),pandoc-citeproc)
filters += ./pandoc-iri
markdown_includes = copyright.md colophon.md
-mediawiki_includes = preface.mw foreword.mw
includes += $(markdown_includes:.md=.tex)
-includes += $(mediawiki_includes:.mw=.tex)
localfilters = $(filter ./%,$(filters))
@@ -58,10 +56,6 @@ $(stem).mw: $(stem).raw
$(stem).native: $(stem).mw $(localfilters)
$(env_filter) pandoc -f mediawiki $(args_meta) $(args_filter) -o $@ $<
-$(mediawiki_includes): $(stem).mw
-$(mediawiki_includes:.mw=.tex): %.tex: %.mw $(stem).mw
- pandoc -f mediawiki -t latex --chapters -o $@ $<
-
$(markdown_includes:.md=.tex): %.tex: %.md
pandoc -f markdown -t latex --chapters -o $@ $<
@@ -70,7 +64,7 @@ $(flavors:%=$(stem)-%.pdf): $(stem)-%.pdf: $(stem).native $(templates) $(include
clean:
rm -f $(foreach ext,native bib mw,$(stem:%=%.$(ext)))
- rm -f $(includes) $(mediawiki_includes)
+ rm -f $(includes)
distclean: clean
rm -f $(stem:%=%.raw)
diff --git a/before.tex b/before.tex
index db8aef3..7509269 100644
--- a/before.tex
+++ b/before.tex
@@ -12,14 +12,3 @@
\setlength{\parskip}{\baselineskip}
\input{copyright}
\endgroup
-
-{
- \hypersetup{linkcolor=black}
- \setcounter{tocdepth}{3}
- \cleartorecto
- \tableofcontents
-}
-
-\input{foreword}
-
-\input{preface}
diff --git a/mediawiki-matter b/mediawiki-matter
index 04f5393..402e430 100755
--- a/mediawiki-matter
+++ b/mediawiki-matter
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# separate frontmatter pieces from mainmatter
+# reorganize frontmatter
use warnings;
use strict;
@@ -13,16 +13,12 @@ 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);
+# swap sections → Copyright, TOC, Foreword, Preface
+s|^((?:.*?\n)?)(= Preface(?:(?!\n=).)*\n)(= Copyright(?:(?!\n=).)*\n)(= Table(?:(?!\n=).)*\n)(= Foreword(?:(?!\n=).)*\n)(=.*)$|$1$3$4$5$2$6|s;
+# drop section Copyright
s|^((?:.*?\n)?)(= Copyright(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
-s|^((?:.*?\n)?)(= Table of Contents(?:(?!\n=).)*\n)(=.*)$|$1$3|s;
-
path($outfile)->spew_utf8($_);
1;
diff --git a/pandoc-memoir b/pandoc-memoir
index 8cf44a4..e28e16a 100755
--- a/pandoc-memoir
+++ b/pandoc-memoir
@@ -23,15 +23,23 @@ sub header {
sub frontmatter {
my $self = shift;
- return [ RawBlock( 'latex', '\\frontmatter' ), header('About'), ]
- if ( $self->name eq 'Header' and $self->level >= 1
- and stringify($self) eq 'About' );
+ return [
+# RawBlock( 'latex', '\\frontmatter' ),
+ RawBlock( 'latex',
+ '{\\hypersetup{linkcolor=black}\\setcounter{tocdepth}{3}\\cleartorecto\\tableofcontents}'
+ ),
+ ]
+ if ( $self->name eq 'Header' and $self->level == 1
+ and stringify($self) =~ /^Table/ );
return;
}
sub mainmatter {
my $self = shift;
- return [ RawBlock( 'latex', '\\mainmatter' ), header(stringify($self)), ]
+ return [
+ RawBlock( 'latex', '\\mainmatter' ),
+ header(stringify($self)),
+ ]
if ( $self->name eq 'Header' and $self->level == 1
and stringify($self) =~ /^Scope/ );
return;
@@ -39,7 +47,10 @@ sub mainmatter {
sub backmatter {
my $self = shift;
- return [ RawBlock( 'latex', '\\backmatter' ), header('References'), ]
+ return [
+ RawBlock( 'latex', '\\backmatter' ),
+ header('References'),
+ ]
if ( $self->name eq 'Header' and $self->level == 1
and stringify($self) =~ /^Notes/ );
return;
@@ -47,11 +58,6 @@ sub backmatter {
sub toc {
my $self = shift;
- return RawBlock( 'latex',
- '{\\hypersetup{linkcolor=black}\\setcounter{tocdepth}{3}\\clearpage\\tableofcontents}'
- )
- if ( $self->name eq 'Header' and $self->level == 1
- and stringify($self) =~ /^Table/ );
return []
if ( $self->name eq 'Para' and stringify($self) =~ /__TOC__/ );
return;