in reply to RE: Monkifying posts is too rough (solution, not rant :)
in thread Monkifying posts is too rough (solution, not rant :)
my $text = q{
I like to <tt><monkify>smile ;-></monkify></tt>
<br>
some code:
<pre><monkify>
my $value = [ qw/one two/ ];
print $value->[1];
</monkify></pre>
};
sub fix {
my $text = shift;
my $good = {
'[' => '[',
']' => ']',
'<' => '<',
'>' => '>',
};
my $bad = join '', map { "\\$_" } keys %{$good};
$text =~ s/([$bad])/$good->{$1}/g;
return $text;
}
$text =~ s/<monkify>(.+?)<\/monkify>/fix($1)/ges;
print $text;
PS: I hope I got this post right for the parser ;-)
-- Casey
|
|---|