sub nifty_highlight_code { my $self = shift; my $html = shift; $html =~ s/\[code syntax\=[\'|\"](.*?)[\'|\"]\](.*?)\[\/code\]/$self->process_code($1,$2)/egs; return $html; } sub process_code { my ($self,$lang,$code)=@_; $lang =~ s/CPP/C/g; my $hl = new Syntax::Highlight::Engine::Kate( language => $lang, substitutions => { "<" => "<", ">" => ">", "&" => "&", " " => " ", "\t" => "   ", }, format_table => { Alert => ["", ""], BaseN => ["", ""], BString => ["", ""], Char => ["", ""], Comment => ["", ""], DataType => ["", ""], DecVal => ["", ""], Error => ["", ""], Float => ["", ""], Function => ["", ""], IString => ["", ""], Keyword => ["", ""], Normal => ["", ""], Operator => ["", ""], Others => ["", ""], RegionMarker => ["", ""], Reserved => ["", ""], String => ["", ""], Variable => ["", ""], Warning => ["", ""], }, ); # my $high = new Text::Highlight(wrapper=>"
%s
\n"); # $code=$high->highlight($lang,$code); # $code =~ s/ /  /g; $code = '
' . $hl->highlightText($code) . '
'; return $code; }