changeset 253:87de6d0befd8

Allow per-entry formatting choices.
author Steve Kemp <steve@steve.org.uk>
date Sun, 25 May 2008 14:41:28 +0100
parents 6f0275379974
children 2b67eb6c74eb
files bin/chronicle
diffstat 1 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 = <ENTRY> )
     {
@@ -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.
     #