C
Chris Johnson
I've written a CGI script that basically emulates the Apache default
page, but with more customizations. One of these is the addition of
content above the file list, and I've decided to use Wikipedia-esque
shorthand.
I've got it pretty much working. Except there are some problems with
the link conversion. (In case you've never seen it,
[[http://www.google.com|Google]] translates to <a
href="http://www.google.com">Google</a>)
I've found that if there's a '+' in the string to be replaced, it
simply won't be replaced. Here's the code that works on most every
situation:
while(/\[\[(.*?)\]\]/g){
$new = $1;
if($new =~ s/^(.*)\|(.*)$/<a href="$1">$2<\/a>/){
s/\[\[$1\|$2\]\]/$new/g;
}
}
The specific input that's having trouble is
[[http://fy.chalmers.se/~appro/linux/DVD+RW/|dvd+rw-tools]]
but the peculiar thing is that if I remove the +'s, it makes the
replacement fine (except for the fact that the link is no longer
valid). So does anyone see why this is happening?
Thanks for your time,
Chris
page, but with more customizations. One of these is the addition of
content above the file list, and I've decided to use Wikipedia-esque
shorthand.
I've got it pretty much working. Except there are some problems with
the link conversion. (In case you've never seen it,
[[http://www.google.com|Google]] translates to <a
href="http://www.google.com">Google</a>)
I've found that if there's a '+' in the string to be replaced, it
simply won't be replaced. Here's the code that works on most every
situation:
while(/\[\[(.*?)\]\]/g){
$new = $1;
if($new =~ s/^(.*)\|(.*)$/<a href="$1">$2<\/a>/){
s/\[\[$1\|$2\]\]/$new/g;
}
}
The specific input that's having trouble is
[[http://fy.chalmers.se/~appro/linux/DVD+RW/|dvd+rw-tools]]
but the peculiar thing is that if I remove the +'s, it makes the
replacement fine (except for the fact that the link is no longer
valid). So does anyone see why this is happening?
Thanks for your time,
Chris