my $link = substr $self->[$offset], 0, $length;
if ($context) {
my $trim = 1;
- my $before = $offset > $context ? $self->[$offset - $context] : '';
+ my $before = $offset > $context ? $self->[$offset - $context] : '.';
for my $match (split //, $before) {
scalar $link =~ /\G\Q$match/g or last;
$trim++;
for my $i (0 .. $#links - 1) {
my ($link, $lastchar) = $links[$i + 1]->[0] =~ /(.*)(.)/;
- $link .= $lastchar eq '.' ? 'a' : chr( ord($lastchar) - 1 )
- unless $lastchar eq 'a';
+ $link .= $lastchar eq 'a' ? '.' : chr( ord($lastchar) - 1 )
+ unless $lastchar eq '.';
+ next if $link eq $links[$i]->[0];
$links[$i]->[1] = $link;
}
$links[-1]->[1] = '';