#!/usr/bin/perl # David Bremner <bremner@unb.ca> 2008-2-28 # placed in the public domain %globaltags=(); $in_code_block=0; $preproc=""; #"!" to use new style preprocessor directives LINE: while(<>){ if (m/^[*]\s*DONE\s*([^:]*)\s*:(.*):$/){ $title=$1; @tags=split(":",$2); foreach $tag (@tags){ $globaltags{$tag}=1; } $filename=$title; $filename=~ s/\s+$//; $filename =~ tr/a-zA-Z0-9_.-/_/cs; $filename .= ".mdwn"; open OUT,">$filename" || die "$!"; print OUT "<span class="createlink">${preproc}meta title=\"$title\"</span>\n"; print OUT "<span class="createlink">${preproc}tag @tags</span>\n"; next LINE; } if (m/^\s+CLOSED:\s+\[(.*)\]/){ $date=$1; print OUT "<span class="createlink">${preproc}meta date=\"$date\"</span>\n"; next LINE } # convert links if (s|\[\[([^\]]+)\]\[([^\]]+)\]\]|[$2]($1)|){ s|\(file:files|(/~bremner/wiki/blog/files|g; } # convert typewriter text s/=([^=]+)=/\`$1\`/g; # convert code block syntax. Not sure which is stupider if (s/^: / /){ print OUT "\n" if (!$in_code_block); $in_code_block=1; } else { $in_code_block=0; } # fix ad-hoc updated notes s/^\s*\*\*\s*UPDATE[D]?/####Update\n/; print OUT; } foreach $tag (keys(%globaltags)){ open OUT,">tags/$tag.mdwn" || die "$!"; print OUT" This feed contains pages in the '$tag' category. <span class="createlink">Discussion\" show=10 actions=yes</span> "; close OUT; }