Pandoc::Filter::Lazy(3) facilitate creation of filters

SYNOPSIS


my $filter = Pandoc::Filter::Lazy->new(
'Header => sub { Header $_->level, [ Str $_->string ] }'
);
if ( $filter->error ) {
say STDERR $lazy->error;
say STDERR $lazy->code;
} else {
$filter->apply(...)
}

DESCRIPTION

This module helps creation of Pandoc::Filter with arguments given as string. The following should result in equivalent filters:

  Pandoc::Walker::action( ... );     #  ...  as code
  Pandoc::Filter::Lazy->new( '...' ) # '...' as string

The script passed as only argument is tried to convert to valid Perl by escaping selectors and adding a missing "sub { ... }"", for instance

  Code|CodeBlock => say $_->class

Is converted to

  'Code|CodeBlock' => sub { say $_->class }

METHODS

In addition to the methods inherited from Pandoc::Filter:

error

Return an error message if compilation of the filter failed.

script

Return the (possibly cleaned) script arguments to create the filter.

code( [ indent => $indent, ] [ function => $function ] )

Return a string of Perl code that can be used to create the same filter.