Pandoc::Filter::Lazy
facilitate creation of filters
- Provided by: libpandoc-elements-perl (Version: 0.15-1)
- Report a bug
facilitate creation of filters
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(...)
}
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 }
In addition to the methods inherited from Pandoc::Filter:
Return an error message if compilation of the filter failed.
Return the (possibly cleaned) script arguments to create the filter.
Return a string of Perl code that can be used to create the same filter.
This module is used in command line scripts pandocwalk and pod2pandoc.