Update the way links look also #7

Merged
peteyboy merged 4 commits from fix-paging-bug into develop 2026-06-18 17:52:48 -04:00

View File

@@ -332,7 +332,7 @@ sub page_links_list
my $count=0;
foreach $link (@page_links){
$count+=1;
$link_list = $link_list . "[$count] $link\n";
$link_list = $link_list . "[>$count] $link\n";
}
return $link_list;
}
@@ -507,16 +507,32 @@ sub add_page_link{
my $linkline = shift;
my $base_url = shift;
my $uri_object;
my $uritext;
my $description;
local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
local $URI::ABS_REMOTE_LEADING_DOTS = 1;
#remember inside of braces, ^ means NOT, so any NOT SPACE letters are selected, so everything up to next space
if (defined($linkline=~ /^=> ([^ ]*)/)){ #has to be something here or I think URI->new_abs has exception that crashes app
if ($linkline=~ /^=> ([^ ]*)/){ #has to be something here or I think URI->new_abs has exception that crashes app
$uri_object=URI->new_abs($linkline=~ /^=> ([^ ]*)/,$base_url);
$uritext = ($linkline=~ s/^=> ([^ ]*).*/$1/r);
chomp($uritext);
push(@page_links, $uri_object->as_string);
my $count = scalar @page_links; #scalar is size/count of links, but $#page_links is highest INDEX
#below puts the [>1] at the end of the description.
#return $linkline =~ s/(^=>.*$)/$1 [\>$count\]/r; don't need to escape on the replace part of a substitution, I guess?
return $linkline =~ s/(^=> .*$)/$1 [>$count]/r;
#below puts the [>1] at the beginning of line, replacing =>
#return $linkline =~ s/^=>/[>$count]/r;
#This reconstructs the uri so it can put the [>1] between the uri and the description, but still on the same
#line as the url, if there isn't a description (was unable to figure out how to do in one regex!)
if ($linkline =~ /=> .* [^\n]+/){
$description = ($linkline=~ s/=> [^ ]+ ([^\n]+)/$1/r);
}
else{
$description= "";
}
return "=> " . $uritext . " [>$count] " . $description . "\n";
}else{
return $linkline;
}