# HG changeset patch # User Steve Kemp # Date 1211722888 -3600 # Node ID 87de6d0befd8d3742a2f6fbc1e2cf97ecba3b849 # Parent 6f02753799748af279e8c2de6d5a5c575a42e969 Allow per-entry formatting choices. diff -r 6f0275379974 -r 87de6d0befd8 bin/chronicle --- a/bin/chronicle Thu May 22 21:24:42 2008 +0100 +++ b/bin/chronicle Sun May 25 14:41:28 2008 +0100 @@ -1483,11 +1483,15 @@ my $title = ""; # entry title. + my $format = ""; # entry format my $tags = ""; # entry tags. my $body = ""; # entry body. my $date = ""; # entry date my $publish = ""; # entry publish date - *ignored* + # + # Read the actual entry + # open( ENTRY, "<", $filename ) or die "Failed to read $filename $!"; while ( my $line = ) { @@ -1502,6 +1506,18 @@ elsif ( ( $line =~ /^publish:(.*)/i ) && !length($publish) ) { $publish = $1; + $publish =~ s/^\s+// if ( length $publish ); + $publish =~ s/\s+$// if ( length $publish ); + } + elsif ( ( $line =~ /^format:(.*)/i ) && !length($format) ) + { + $format = $1; + if ( length $format ) + { + $format =~ s/^\s+//; + $format =~ s/\s+$//; + $format = lc($format); + } } elsif ( ( $line =~ /^(Subject|Title):(.*)/i ) && !length($title) ) { @@ -1551,11 +1567,28 @@ } + + # + # If we didn't have a per-entry format then revert to the + # global one, if any. + # + if ( !length($format) ) + { + if ( $CONFIG{ 'format' } ) + { + $format = lc( $CONFIG{ 'format' } ); + } + else + { + $format = 'html'; + } + } + + + # # Determine the input format to use. # - my $format = lc( $CONFIG{ 'format' } ); - # # Now process accordingly. #