# #
# File: shared/Encode/Posting.pm #
# #
-# Authors: André Malo <nd@o3media.de>, 2001-04-10 #
+# Authors: André Malo <nd@o3media.de> #
# #
# Description: prepare a Posting text for saving and visual (HTML) output #
# #
################################################################################
use strict;
+use vars qw(
+ @EXPORT
+);
use Encode::Plain; $Encode::Plain::utf8 = 1;
use CheckRFC;
+################################################################################
+#
+# Version check
+#
+# last modified:
+# $Date$ (GMT)
+# by $Author$
+#
+sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
+
################################################################################
#
# Export
#
use base qw(Exporter);
-@Encode::Posting::EXPORT = qw(
+@EXPORT = qw(
encoded_body
answer_field
message_field
my @rawlinks;
push @rawlinks => [$1 => $2] while ($posting =~ /\[([Ll][Ii][Nn][Kk]):\s*([^\]\s]+)\s*\]/g);
my @links = grep {
- is_URL ( $_ -> [1] => ':ALL')
+ is_URL ( $_ -> [1] => qw(http ftp news nntp telnet gopher mailto))
or is_URL (($_ -> [1] =~ /^[Vv][Ii][Ee][Ww]-[Ss][Oo][Uu][Rr][Cc][Ee]:(.+)/)[0] || '' => 'http')
or ( $_ -> [1] =~ m<^(?:\.?\.?/(?!/)|\?)>
and is_URL (rel_uri ($_ -> [1], $base) => 'http'))
my $area = $$posting;
my $qchar = $params -> {quoteChars};
- $area =~ s/<br>/\n/g; # <br> => \n
- $area =~ s/&(?:#160|nbsp);/ /g; # nbsp => ' '
+ $area =~ s/<br(?:\s*\/)?>/\n/g; # <br> => \n
+ $area =~ s/&(?:#160|nbsp);/ /g; # nbsp => ' '
$area =~ s/^(.)/\177$1/gm if ($params -> {quoteArea}); # shift a quoting character
$area =~ s/^(\177+)/$qchar x length ($1)/gem; # decode normalized quoting characters
my $posting = ${+shift};
my $params = shift || {};
- my $break = '<br>';
+ my $break = '<br />';
if ($params -> {quoting}) { # quotes are displayed as special?
my @array = [0 => []];
- for (split /<br>/ => $posting) {
+ for (split /<br(?:\s*\/)?>/ => $posting) {
my $l = length ((/^(\177*)/)[0]);
if ($array[-1][0] == $l) {
push @{$array[-1][-1]} => $_;
shift @array unless @{$array[0][-1]};
my $ll=0;
- $posting = join '<br>' => map {
+ $posting = join $break => map {
my $string = $_->[0]
? (($ll and $ll != $_->[0]) ? $break : '') .
join join ($break => @{$_->[-1]})
\$posting;
}
-# keeping 'require' happy
+# keep 'require' happy
1;
#