line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#============================================================= -*-Perl-*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Template::Plugin::HTML::BBCode |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# Wrapper around HTML::BBCode module |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Igor Lobanov |
10
|
|
|
|
|
|
|
# http://www.template-toolkit.ru/ |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# COPYRIGHT |
13
|
|
|
|
|
|
|
# Copyright (C) 2005 Igor Lobanov. All Rights Reserved. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
16
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
#============================================================================ |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Template::Plugin::HTML::BBCode; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
24626
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
23
|
1
|
|
|
1
|
|
6
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
24
|
1
|
|
|
1
|
|
938
|
use Template::Plugin::Filter; |
|
1
|
|
|
|
|
8283
|
|
|
1
|
|
|
|
|
34
|
|
25
|
1
|
|
|
1
|
|
10
|
use base qw( Template::Plugin::Filter ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
26
|
1
|
|
|
1
|
|
1027
|
use HTML::BBCode; |
|
1
|
|
|
|
|
39625
|
|
|
1
|
|
|
|
|
240
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 0.01 $ =~ /(\d+)\.(\d+)/); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Filter name |
31
|
|
|
|
|
|
|
my $DEFAULT_FILTER_NAME = 'bbcode'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Internal hash with parsers |
34
|
|
|
|
|
|
|
my $PARSERS = {}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# init defines filter name (first positional argument) |
37
|
|
|
|
|
|
|
sub init { |
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
39
|
0
|
|
|
|
|
|
$self->{_DYNAMIC} = 1; |
40
|
0
|
|
0
|
|
|
|
$self->install_filter( $self->{_ARGS}->[0] || $DEFAULT_FILTER_NAME ); |
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub filter { |
45
|
0
|
|
|
0
|
0
|
|
my ( $self, $text, undef, $conf ) = @_; |
46
|
0
|
|
0
|
|
|
|
$conf = $self->merge_config( $conf ) || {}; |
47
|
|
|
|
|
|
|
# Create single BBCode object for each set of parameters - $pset |
48
|
0
|
0
|
|
|
|
|
my $pset = join('', map { |
|
|
0
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
(ref($_) eq 'HASH') ? join('', %$_) : (ref($_) eq 'ARRAY') ? join('', @$_) : $_ |
50
|
|
|
|
|
|
|
} %$conf); |
51
|
0
|
0
|
|
|
|
|
my $parser = (exists $PARSERS->{$pset}) ? $PARSERS->{$pset} : $PARSERS->{$pset} = HTML::BBCode->new( $conf ); |
52
|
0
|
|
|
|
|
|
return $parser->parse( $text ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |