summaryrefslogtreecommitdiff
path: root/pandoc-memoir
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2014-12-25 18:19:55 +0100
committerJonas Smedegaard <dr@jones.dk>2014-12-25 18:19:55 +0100
commit5cbb6b9dca11fe98b2feefcd31684ee2c2f1455a (patch)
treeeef9ca15ab02bfc1873d3875350faa671188fea9 /pandoc-memoir
parent7912a20b53c06e5eb8ef9682d06bd57429a87fca (diff)
Rename and shorten filters.
Diffstat (limited to 'pandoc-memoir')
-rwxr-xr-xpandoc-memoir55
1 files changed, 55 insertions, 0 deletions
diff --git a/pandoc-memoir b/pandoc-memoir
new file mode 100755
index 0000000..f0bb5a5
--- /dev/null
+++ b/pandoc-memoir
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Pandoc::Filter;
+use Pandoc::Elements;
+
+# FIXME: avoid eating content past tweaked headers
+pandoc_filter(
+ \&frontmatter,
+ \&mainmatter,
+ \&backmatter,
+ \&toc,
+);
+
+# FIXME: use Header (not latex RawBlock) - why does it hang?!?
+sub header {
+ my $label = shift;
+# Header( 1, attributes {}, [ Str $label ], );
+ RawBlock( 'latex', '\\chapter{'.$label.'}' );
+};
+
+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;
+}
+
+sub mainmatter {
+ my $self = shift;
+ return [ RawBlock( 'latex', '\\mainmatter' ), header(stringify($self)), ]
+ if ( $self->name eq 'Header' and $self->level == 1
+ and stringify($self) =~ /^Scope/ );
+ return;
+}
+
+sub backmatter {
+ my $self = shift;
+ return [ RawBlock( 'latex', '\\backmatter' ), header('References'), ]
+ if ( $self->name eq 'Header' and $self->level == 1
+ and stringify($self) =~ /^Notes/ );
+ return;
+}
+
+sub toc {
+ my $self = shift;
+ return unless ( $self->name eq 'Header' and $self->level == 1
+ and stringify($self) =~ /^Table/ );
+ return RawBlock( 'latex',
+ '{\\hypersetup{linkcolor=black}\\setcounter{tocdepth}{3}\\tableofcontents}'
+ );
+}