Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using filters consecutively don't work #22

Open
MaxPerl opened this issue Jan 24, 2017 · 0 comments
Open

Using filters consecutively don't work #22

MaxPerl opened this issue Jan 24, 2017 · 0 comments

Comments

@MaxPerl
Copy link

MaxPerl commented Jan 24, 2017

If I use filters consecutively,then only the first filter is processed. All other filters are treated as tables-
See this example:

use Text::Textile;

my $textile = new Text::Textile;

# define a hash of filters,
# here we just have one
$textile->filters(
    {
    test => sub {
          my ( $text, $param ) = (@_);
            # $text contains the string between the last
            # '|' and the '==', here I expect a number
            $text =~ s/(\d+)/http::\/\/localhost\/item\/view\/$1/;
           return $text;
           },
    video => sub {
            my ( $text, $r_param_list ) = (@_);
            # $text contains the string between the last
            # '|' and the '==', here I expect a number
            $text =~ s/(.*)###(.*)/\<video src\=\"$1\">$2<\/video\>/;
            return $text;
            },
    
    }
);


# Set the base URL as parameter (localhost for test)
$textile->filter_param( [ $base_url ] );

# generate the result
while ( my $line = <DATA>) { $lines = $lines.$line;}
#chomp @lines;
$dest = $textile->process($lines);

# $dest is the result
print "ERGEBNIS $dest\n";

__DATA__
==|video|/home/maximilian/video.mp2###Video ansehen==

==|video|/home/maximilian/video.mp2###Video ansehen==

==|item|12==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant