| 1 | # $Id: CODE.pm 284 2006-12-01 07:51:49Z chronos $ | ||||||||||
| 2 | package BBCode::Tag::CODE; | ||||||||||
| 3 | 2 | ▶ | use base qw(BBCode::Tag::Block); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use BBCode::Util qw(encodeHTML multilineText); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | our $VERSION = '0.34'; | |||||||||
| 8 | |||||||||||
| 9 | 8 | ▶ | sub BodyPermitted($):method { | ||||||||
|
Subroutine
BodyPermitted: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 10 | 8 | return 1; | |||||||||
| 11 | } | ||||||||||
| 12 | |||||||||||
| 13 | 6 | ▶ | sub BodyTags($):method { | ||||||||
|
Subroutine
BodyTags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 6 | return qw(:TEXT URL EMAIL); | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 4 | ▶ | sub NamedParams($):method { | ||||||||
|
Subroutine
NamedParams: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | 4 | return qw(LANG); | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub RequiredParams($):method { | ||||||||
|
Subroutine
RequiredParams: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | 0 | return (); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 2 | ▶ | sub validateParam($$$):method { | ||||||||
|
Subroutine
validateParam: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 26 | 2 | my($this,$param,$val) = @_; | |||||||||
| 27 | 2 | ▶ | if($param eq 'LANG') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 2 | $val =~ s/_/-/g; | |||||||||
| 29 | 2 | ▶ | if($val =~ /^ \w+ (?: - \w+ )* $/x) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 1 | return $val; | |||||||||
| 31 | } else { | ||||||||||
| 32 | 1 | die qq(Invalid value "$val" for [CODE LANG]); | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | 0 | return $this->SUPER::validateParam($param,$val); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | sub toHTML($):method { | ||||||||
|
Subroutine
toHTML: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 39 | 1 | my $this = shift; | |||||||||
| 40 | 1 | my $pfx = $this->parser->css_prefix; | |||||||||
| 41 | |||||||||||
| 42 | 1 | my $lang = $this->param('LANG'); | |||||||||
| 43 | 1 | my $body = $this->bodyHTML; | |||||||||
| 44 | 1 | $body =~ s#<br/>$##mg; | |||||||||
| 45 | 1 | $body =~ s#<br/>#\n#g; | |||||||||
| 46 | 1 | ▶ | return multilineText | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | qq(<div class="${pfx}code">\n), | ||||||||||
| 48 | qq(<div class="${pfx}code-head">), (defined $lang ? encodeHTML(ucfirst "$lang ") : ""), qq(Code:</div>\n), | ||||||||||
| 49 | qq(<pre class="${pfx}code-body">\n), | ||||||||||
| 50 | qq($body\n), | ||||||||||
| 51 | qq(</pre>\n), | ||||||||||
| 52 | qq(</div>\n); | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 2 | 1; | |||||||||