changeset 178:2353a39f57e6

Handle non-alphanumerical characters in titles.
author Steve Kemp <steve@steve.org.uk>
date Tue, 01 Apr 2008 22:16:25 +0100
parents 210e50f5e1bf
children 9605ec6f91af
files bin/chronicle
diffstat 1 files changed, 37 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/bin/chronicle	Tue Apr 01 22:10:04 2008 +0100
+++ b/bin/chronicle	Tue Apr 01 22:16:25 2008 +0100
@@ -584,6 +584,11 @@
     #
     my $pattern = $CONFIG{'pattern'} || "*";
 
+
+
+    #
+    #  Find the filenames.
+    #
     foreach my $file ( sort( glob( $CONFIG{'input'} . "/" . $pattern ) ) )
     {
 
@@ -606,8 +611,8 @@
     {
         print <<EOF;
 
-  There were no text files found in the input directory
- $CONFIG{'input'} which matched the pattern '$pattern'.
+  There were no files found in the input directory $CONFIG{'input'}
+ which matched the pattern '$pattern'.
 
   Aborting.
 
@@ -635,7 +640,7 @@
 
     foreach my $f ( keys %data )
     {
-        my $h = $data{$f};
+        my $h    = $data{$f};
         my $tags = $h->{'tags'} || undef;
         foreach my $t (@$tags)
         {
@@ -667,7 +672,6 @@
 
     foreach my $key ( sort keys(%unique) )
     {
-
         # count.
         my $count = $unique{$key};
 
@@ -1134,8 +1138,14 @@
         my $blog = readBlogEntry($f);
         if ( keys(%$blog) )
         {
+            #
+            #  Test for the cut in a quick fashion.
+            #
             if ( $blog->{'body'} =~ /<cut/i )
             {
+                #
+                #  Properly process a "cut"
+                #
                 $blog->{'body'} =
                   processCut( $blog->{'body'}, $blog->{'link'} );
             }
@@ -1204,7 +1214,21 @@
 
 =begin doc
 
-  Process the body for <cut text="xx"></cut>
+  Process the body for any present cut tags which might be present.
+
+  The cut text looks like this:
+
+=for example begin
+
+   Blah blah
+   This is visible
+   <cut [text="xx"]>
+   This is hidden
+   So is this
+   </cut>
+   This is visible
+
+=for example end
 
 =end doc
 
@@ -1669,16 +1693,18 @@
 {
     my ($file) = (@_);
 
+    #
+    #  Strip suffix.
+    #
     if ( $file =~ /(.*)\.(.*)/ )
     {
         $file = $1;
     }
-    $file =~ s/ /_/g;
-    $file =~ s/'/_/g;
-    $file =~ s/!/_/g;
-    $file =~ s/\?/_/g;
-    $file =~ s/\///g;
-    $file =~ s/\\//g;
+
+    #
+    #  Get rid of non-alphanumerical characters
+    #
+    $file =~ s/[^a-z0-9]/_/gi;
 
     my $suffix = $CONFIG{'suffix'} || ".html";
     $file .= $suffix;