# HG changeset patch # User steve # Date 1187098770 0 # Node ID 057cd84ce271f1c7924b72f8a5f6031f3c413922 # Parent 6d7827134a4fe9cd27592a2bbaa67cf5bc9d20b5 2007-08-14 13:39:30 by steve Strip leading/trailing spaces from titles. diff -r 6d7827134a4f -r 057cd84ce271 bin/chronicle --- a/bin/chronicle Mon Aug 13 23:22:03 2007 +0000 +++ b/bin/chronicle Tue Aug 14 13:39:30 2007 +0000 @@ -54,7 +54,7 @@ -- http://www.steve.org.uk/ - $Id: chronicle,v 1.4 2007-08-13 23:17:15 steve Exp $ + $Id: chronicle,v 1.5 2007-08-14 13:39:30 steve Exp $ =cut @@ -294,7 +294,7 @@ if ( $VERSION ) { - my $REVISION = '$Revision: 1.4 $'; + my $REVISION = '$Revision: 1.5 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { $REVISION = $1; @@ -361,7 +361,7 @@ open( INPUT, "<", $file ) or die "Failed to open blog file $file - $!"; while( my $line = ) { - if ( $line =~ /^tags: (.*)/i ) + if ( $line =~ /^tags:(.*)/i ) { my $tag .= $1; foreach my $t ( split( /,/, $tag ) ) @@ -378,17 +378,31 @@ push ( @tags, $t ); } } - elsif (( $line =~ /^title: (.*)/i ) && !length($title) ) + elsif (( $line =~ /^title:(.*)/i ) && !length($title) ) { $title = $1; + + # strip leading and trailing space. + $title =~ s/^\s+// if ( length $title ); + $title =~ s/\s+$// if ( length $title ); } - elsif (( $line =~ /^date: (.*)/i ) && !length($date) ) + elsif (( $line =~ /^date:(.*)/i ) && !length($date) ) { $date = $1; + + # strip leading and trailing space. + $date =~ s/^\s+// if ( $date ); + $date =~ s/\s+$// if ( $date ); + } - elsif ( $line =~ /^status: (.*)/i ) + elsif ( $line =~ /^status:(.*)/i ) { my $level = $1; + + # strip leading and trailing space. + $level =~ s/^\s+// if ( $level ); + $level =~ s/\s+$// if ( $level ); + $private = 1 if ( $level =~ /private/i); } } @@ -1035,10 +1049,12 @@ my %entry; - my $title = ""; - my $tags = ""; - my $body = ""; - my $date = ""; + my $title = ""; + my $tags = ""; + my $body = ""; + my $date = ""; + my $status = ""; + open( ENTRY, "<", $filename ) or die "Failed to read $filename $!"; while( my $line = ) @@ -1053,10 +1069,22 @@ elsif (( $line =~ /^title: (.*)/i ) && !length($title) ) { $title = $1; + + # strip leading and trailing space. + $title =~ s/^\s+// if ( length $title ); + $title =~ s/\s+$// if ( length $title ); } elsif (( $line =~ /^date: (.*)/i ) && !length($date) ) { $date = $1; + + # strip leading and trailing space. + $date =~ s/^\s+// if ( length $date ); + $date =~ s/\s+$// if ( length $date ); + } + elsif (( $line =~ /^status:(.*)/ ) && !length ( $status ) ) + { + $status = $1; } else {