Initial uri parsing support
This commit is contained in:
parent
1abb52c99a
commit
81a6c52032
34
II/T.pm
34
II/T.pm
@ -167,13 +167,40 @@ sub pre {
|
||||
$post =~ s/>(.+)/<font color='green'>>$1<\/font>/g;
|
||||
$post =~ s/--/—/g;
|
||||
$post =~ s/.?\*(.+)\*.?/ <b>$1<\/b> /g;
|
||||
$post =~ s/^$/<br>\n/g;
|
||||
$post =~ s/(.?)\n/$1<br>\n/g;
|
||||
$post =~ s/\*(.+)/<li>$1<\/li>\n/g;
|
||||
|
||||
# URI's parsing
|
||||
if ( $post =~ m!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?! ) {
|
||||
|
||||
print "\n2:=$2=\n";
|
||||
# Images
|
||||
if ( $9 !=~ m/.+\.(jpg|png|gif)/ ) {
|
||||
$post
|
||||
=~ s/(https?:\/\/.+)/<a href="$1">$1<\/a>/g;
|
||||
}
|
||||
elsif ( $9 =~ m/.+\.((jpg|png|gif)|(JPG|PNG|GIF))/ ) {
|
||||
$post
|
||||
=~ s/(https?:\/\/.+\.(jpg|png|gif))/<a href="$1"><img src="$1" width="15%" height="15%" \/><\/a>/g;
|
||||
$post
|
||||
=~ s/(https?:\/\/.+\.(JPG|PNG|GIF))/<a href="$1"><img src="$1" width="15%" height="15%" \/><\/a>/g;
|
||||
}
|
||||
elsif ( $2 eq 'ii' ) {
|
||||
# ii uri
|
||||
$post =~ s/ii:\/\/(.+\.\d{1,4}),?.+/<a href="\/e?echo=$1&view=thread">$1<\/a>/g;
|
||||
$post =~ s/ii:\/\/(.{20})/<a href="\/send?hash=$1">$1<\/a>/g;
|
||||
}
|
||||
}
|
||||
|
||||
$post =~ s/^$/<br>\n/g;
|
||||
$post =~ s/(.?)\n/$1<br>\n/g;
|
||||
$post =~ s/\*(.+)/<li>$1<\/li>\n/g;
|
||||
|
||||
|
||||
# Url
|
||||
# use Regexp::Common "URI";
|
||||
# $post =~ s( ($RE{URI}{HTTP}) )
|
||||
# (<a href="$1">$1</a>)gx;
|
||||
|
||||
|
||||
# Not are regexp parsing
|
||||
my $pre = 0;
|
||||
my $txt;
|
||||
@ -192,6 +219,7 @@ sub pre {
|
||||
$txt .= $line;
|
||||
}
|
||||
close $fh;
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user