summaryrefslogtreecommitdiff
path: root/pandoc-memoir
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2015-01-15 17:29:39 +0100
committerJonas Smedegaard <dr@jones.dk>2015-01-15 18:55:52 +0100
commit5d5cc53911e989349033645790ae9b3997e17b51 (patch)
tree1cf514b5849bcb1043e1e47f7c987a08638a1207 /pandoc-memoir
parent479bae5fc69ef0c35f102ef569d1b4356f8ebd32 (diff)
Add loop check in memoir filter, and return Header (not latex RawBlock).
Diffstat (limited to 'pandoc-memoir')
-rwxr-xr-xpandoc-memoir20
1 files changed, 8 insertions, 12 deletions
diff --git a/pandoc-memoir b/pandoc-memoir
index b4158e7..cb02d62 100755
--- a/pandoc-memoir
+++ b/pandoc-memoir
@@ -9,39 +9,35 @@ no if $] >= 5.018, warnings => "experimental::smartmatch";
use Pandoc::Filter 0.06;
use Pandoc::Elements;
+my ( $frontmatter_seen, $mainmatter_seen, $backmatter_seen);
+
pandoc_filter(
\&matter,
\&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 matter {
my $self = shift;
return unless ( $self->name eq 'Header' );
return unless ( $self->level == 1 );
given (stringify($self)) {
- when (/^Table/) {
+ when ( /^Table/ and not $frontmatter_seen++ ) {
return [
# RawBlock( 'latex', '\\frontmatter' ),
RawBlock( 'latex',
'{\\hypersetup{linkcolor=black}\\setcounter{tocdepth}{3}\\cleartorecto\\tableofcontents}'
),
] };
- when (/^Scope/) {
+ when ( /^Scope/ and not $mainmatter_seen++ ) {
return [
RawBlock( 'latex', '\\mainmatter' ),
- header(stringify($self)),
+ $self,
] };
- when (/^Notes/) {
+ when ( /^Notes/ and not $backmatter_seen++ ) {
return [
RawBlock( 'latex', '\\backmatter' ),
- header('References'),
+ Header( 1, attributes {},
+ [ Str 'References' ] ),
] };
default { return };
}