| 1 | package Text::Trac; | ||||||||||
| 2 | |||||||||||
| 3 | 53 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 53 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 53 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 53 | ▶ | use Text::Trac::Context; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 53 | ▶ | use Text::Trac::BlockNode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 53 | our $VERSION = '0.23'; | |||||||||
| 11 | |||||||||||
| 12 | 53 | my %Defaults = ( | |||||||||
| 13 | html => '', | ||||||||||
| 14 | permalink => '', | ||||||||||
| 15 | min_heading_level => 1, | ||||||||||
| 16 | class => 1, | ||||||||||
| 17 | id => 1, | ||||||||||
| 18 | span => 1, | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | sub new { | ||||||||||
| 22 | 48 | ▶ | my ( $class, %args ) = @_; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | |||||||||||
| 24 | 48 | my $self = { %Defaults, %args, }; | |||||||||
| 25 | |||||||||||
| 26 | 48 | bless $self, $class; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | sub parse { | ||||||||||
| 30 | 160 | ▶ | my $self = shift; | ||||||||
|
Subroutine
parse: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 31 | 160 | ▶ | my $text = shift or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 160 | ▶ | $self->{trac_url} = '/' unless defined $self->{trac_url}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 160 | for ( keys %$self ) { | |||||||||
| 35 | 1190 | ▶ | if ( $_ =~ /^trac.+url$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 224 | ▶ | $self->{$_} .= '/' if $self->{$_} !~ m!/$!; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 160 | my $c = Text::Trac::Context->new( | |||||||||
| 41 | { | ||||||||||
| 42 | %$self, text => $text, | ||||||||||
| 43 | } | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 160 | my $node = Text::Trac::BlockNode->new( | |||||||||
| 47 | { | ||||||||||
| 48 | context => $c, | ||||||||||
| 49 | } | ||||||||||
| 50 | ); | ||||||||||
| 51 | 160 | $node->parse; | |||||||||
| 52 | |||||||||||
| 53 | 160 | $self->{html} = $c->html; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 160 | ▶ | sub html { $_[0]->{html}; } | ||||||||
|
Subroutine
html: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 53 | *process = \&parse; | |||||||||
| 59 | |||||||||||
| 60 | 53 | 1; | |||||||||
| 61 | __END__ | ||||||||||