Subject: | Trac link for Comments |
Hi, I'd like to add one more file lib/Text/Trac/LinkResolver/Comment.pm
to handle 'comment:ticket:<ticketId>:<commentId>'
package Text::Trac::LinkResolver::Comment;
use strict;
use base qw( Text::Trac::LinkResolver );
sub init {
my $self = shift;
$self->{pattern} = '!?(?<!&)comment:ticket:\d+:\d+';
}
sub format_link {
my ( $self, $match, $target, $label ) = @_;
return $match if $self->_is_disabled;
my $c = $self->{context};
$label ||= $match;
my ( $rev,$commentId ) = ( $match =~ m/(\d+):(\d+)/ );
my $url = $c->{trac_ticket_url} || $c->trac_url . 'ticket/';
$url .= $rev;
$url .= "#$commentId";
return sprintf '<a class="ticket" href="%s">%s</a>', $url, $label;
}
1;
And here is the test I append in t/03-trac-links.t
### comment link test 1
--- input
comment:ticket:1:8
--- expected
<p>
<a class="ticket"
href="http://trac.mizzy.org/public/ticket/1#8">comment:ticket:1:8</a>
</p>