#!/usr/bin/perl print qq|Content-Type: text/html \n\n|; use Parse::BBCode; # \[\[([^]]+)\|([^]]+)\]\] my $test = qq|==Getting There== testing [ref]bla bla bla [[http://www.google.com]] test and [[http://www.google.com\|testing]] [/ref] hhh testing [ref]bla bla bla an[/ref] hhh |; my $p = Parse::BBCode->new({ tags => { # load the default tags Parse::BBCode::HTML->defaults, # add/override tags url => 'url:%{parse}s', i => '%{parse}s', b => '%{parse}s', noparse => '
%{html}s',
code => sub {
my ($parser, $attr, $content, $attribute_fallback) = @_;
if ($attr eq 'perl') {
# use some syntax highlighter
$content = highlight_perl($content);
}
else {
$content = Parse::BBCode::escape_html($$content);
}
"$content"
},
test => 'this is klingon: %{klingon}s',
},
escapes => {
klingon => sub {
my ($parser, $tag, $text) = @_;
return translate_into_klingon($text);
},
},
}
);
my $code = $test;
my $parsed = $p->render($code);
use Data::Dumper;
print Dumper($parsed);