summaryrefslogtreecommitdiff
path: root/pandoc-memoir
diff options
context:
space:
mode:
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 };
}