summaryrefslogtreecommitdiff
path: root/pandoc-memoir
blob: e28e16ab7ce69f899fe67696b956c3388c47459b (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Pandoc::Filter 0.05;
  5. use Pandoc::Elements;
  6. # FIXME: avoid eating content past tweaked headers
  7. pandoc_filter(
  8. \&frontmatter,
  9. \&mainmatter,
  10. \&backmatter,
  11. \&toc,
  12. );
  13. # FIXME: use Header (not latex RawBlock) - why does it hang?!?
  14. sub header {
  15. my $label = shift;
  16. # Header( 1, attributes {}, [ Str $label ], );
  17. RawBlock( 'latex', '\\chapter{'.$label.'}' );
  18. };
  19. sub frontmatter {
  20. my $self = shift;
  21. return [
  22. # RawBlock( 'latex', '\\frontmatter' ),
  23. RawBlock( 'latex',
  24. '{\\hypersetup{linkcolor=black}\\setcounter{tocdepth}{3}\\cleartorecto\\tableofcontents}'
  25. ),
  26. ]
  27. if ( $self->name eq 'Header' and $self->level == 1
  28. and stringify($self) =~ /^Table/ );
  29. return;
  30. }
  31. sub mainmatter {
  32. my $self = shift;
  33. return [
  34. RawBlock( 'latex', '\\mainmatter' ),
  35. header(stringify($self)),
  36. ]
  37. if ( $self->name eq 'Header' and $self->level == 1
  38. and stringify($self) =~ /^Scope/ );
  39. return;
  40. }
  41. sub backmatter {
  42. my $self = shift;
  43. return [
  44. RawBlock( 'latex', '\\backmatter' ),
  45. header('References'),
  46. ]
  47. if ( $self->name eq 'Header' and $self->level == 1
  48. and stringify($self) =~ /^Notes/ );
  49. return;
  50. }
  51. sub toc {
  52. my $self = shift;
  53. return []
  54. if ( $self->name eq 'Para' and stringify($self) =~ /__TOC__/ );
  55. return;
  56. }