/usr/share/perl5/Text/Trac/Ol.pm is in libtext-trac-perl 0.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | package Text::Trac::Ol;
use strict;
use base qw(Text::Trac::BlockNode);
sub init {
my $self = shift;
$self->pattern(qr/(\s+) ([\daiAI])\. \s+ (.*)$/xms);
return $self;
}
sub parse {
my ( $self, $l ) = @_;
my $c = $self->{context};
my $pattern = $self->pattern;
$l =~ $pattern or return $l;
my $type = $2;
my $space = length($1);
my $level = $c->ol->{level} || 0;
$c->ol->{space} ||= 0;
my $start_tag;
if ($type =~ /(\d)/){
$start_tag = $type == 1 ? '<ol>' : qq{<ol start="$1">};
}
elsif ($type eq 'a'){
$start_tag = qq{<ol class="loweralpha">};
}
elsif ($type eq 'A'){
$start_tag = qq{<ol class="upperalpha">};
}
elsif ($type eq 'i'){
$start_tag = qq{<ol class="lowerroman">};
}
elsif ($type eq 'I'){
$start_tag = qq{<ol class="upperroman">};
}
if ( $space > $c->ol->{space} ){
for ( 1 .. ( $space + 1 ) / 2 - $level ) {
$l = $start_tag . $l;
$level++;
}
}
elsif ( $space < $c->ol->{space} ){
for ( 1 .. ( $c->ol->{space} - $space ) / 2 ) {
$l = '</li></ol>' . $l;
$level--;
}
$l =~ s!(?<=</(?:ol|li)>)(?= )!</li>!;
}
else {
$l = "</li>$l";
}
$c->ol({level => $level, space => $space });
# parse inline nodes
$l =~ s{ $pattern }{'<li>' . $self->replace($3)}xmsge;
if ($c->hasnext and $c->nextline =~ $pattern){
$self->parse($l);
}
else {
for ( 1 .. $c->ol->{level} ){
$l .= '</li></ol>';
}
$c->ol->{level} = 0;
$c->ol->{space} = 0;
}
$c->htmllines($l);
return;
}
1;
|