diff --git a/orrg.pl b/orrg.pl
index 7d4a9bf834d306ca23fa7c023542f5454a899efc..6cc6843b64bc39ddcad803b98702e67ac271c489 100755
--- a/orrg.pl
+++ b/orrg.pl
@@ -44,10 +44,10 @@ push @body, ('# orrg error', '', 'The requested feed could not be loaded. :(', '', '=> '. $qs .' open feed in browser');
return @body;
}
- push @body, '# '. $feed->title;
+ push @body, '# '. trim_ws($feed->title);
push @body, 'fetched '. strftime('%Y-%m-%dT%H:%M:%SZ', gmtime());
push @body, '';
- $feed->description eq '' or push @body, $feed->description;
+ $feed->description eq '' or push @body, trim_ws($feed->description);
$feed->image eq '' or push @body, '=> '. $feed->image .' feed image';
$feed->link eq '' or push @body, ('=> '.$feed->link.' open website', '');
@@ -63,33 +63,38 @@ my ($it) = @_;
my $hs = HTML::Strip->new(emit_spaces => 0, auto_reset => 1);
my @item = ();
- my $title = $it->title;
- my $link = $it->link;
- $title =~ s/^\s+//ig;
- $title =~ s/\s+$//ig;
- $link =~ s/^\s+//ig;
- $link =~ s/\s+$//ig;
- push @item, (($it->description ne '' && $it->description ne $it->title) || $it->pubDate ne '')? '## '. $title : $title;
+ my $title = trim_ws($it->title);
+ my $link = trim_ws($it->link);
+ my $desc = $it->description;
+ if ($desc ne '') {
+ $desc =~ s/\<li\>/* /igm;
+ $desc =~ s/\<h[1-2][^\>]+\>/### /igm;
+ $desc =~ s/\<br \/\>/\r\n/igm;
+ $desc = $hs->parse($desc);
+ $desc = trim_ws($desc);
+ }
+ push @item, (($desc ne '' && $desc ne $title) || $it->pubDate ne '')? '## '. $title : $title;
if ($it->pubDate ne '') {
my $dt = DateTime::Format::ISO8601->parse_datetime($it->pubDate);
push @item, 'published '. strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($dt->epoch));
push @item, '';
}
- if ($it->description ne '' && $it->description ne $it->title) {
- my $desc = $it->description;
- $desc =~ s/\<li\>/* /igm;
- $desc =~ s/\<h[1-2][^\>]+\>/### /igm;
- $desc =~ s/\<br \/\>/\r\n/igm;
- $desc = $hs->parse($desc);
- $desc =~ s/^\r\n$//igm;
- $desc =~ s/^\s+\*/*/igm;
- $desc =~ s/\s+$//igm;
- $desc =~ s/^\s+//igm;
+ if ($desc ne '' && $desc ne $title) {
push @item, $desc;
}
$link eq '' or push @item, ('=> '.$link.' open entry in browser', '');
return \@item;
+}
+
+sub trim_ws
+{
+ my ( $string ) = @_;
+ $string =~ s/^\s+\*/*/igm;
+ $string =~ s/\s+$//igm;
+ $string =~ s/^\s+//igm;
+ $string =~ s/^\r\n$//igm;
+ return $string;
}
sub feed_get