# Blosxom3 Plugin: blok # Author(s): Stu MacKenzie # Version: 2004-05-30 (v3.0a) # blok docs: http://www.enilnomi.net/download.html # More notes at the bottom of this file or type: perldoc blok # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # The blok plugin intercepts the "story" subroutine and # converts Mac (ascii 13) or Windows (ascii 10,13) line-ends # to the "newline" (ascii 10) that blosxom expects. # The blok plugin intercepts entry file text, converting # Mac (ascii 13) or Windows (ascii 10,13) line-ends # to the "newline" (ascii 10) that blosxom expects. # This enables you to stop thinking about the line-end # format in your word processor, and whether your ftp # app is properly converting your native line-ends. # (Also helpful for processing writebacks?) package Blosxom::Plugin::blok; sub run { my $self = shift; my $title_ref = \$self->{state}->{current_entry}->{title}; my $body_ref = \$self->{state}->{current_entry}->{body}; # Blosxom expects \n line endings (ascii 10), but macs might use # \r (ascii 13), and windows might use \r\n (ascii 13,10); we'll # just clean that up... if ($$title_ref =~ m/\r/) { # convert first return to newline $$title_ref =~ s/\r/\n/; # re-populate the two vars my $temp; ($$title_ref,$temp) = split /\n/, $$title_ref, 2; $$body_ref = $temp . $$body_ref; } if ($$body_ref =~ m/\r/) { # convert leading line-ends into double newline $$body_ref =~ s/^\r\n/\n\n/ or $$body_ref =~ s/^\r/\n\n/; # convert any winlines in $body into newlines $$body_ref =~ s/\r\n/\n/gm; # convert any maclines in $body into newlines $$body_ref =~ s/\r/\n/gm; } 1; } 1; __END__ =head1 NAME Blosxom3 Plug-in: blok -- converts Mac and Windows line-endings to Unix lines. =head1 SYNOPSIS Use blok to sort out line-ends from Mac, *nix, or Windows for processing by blosxom. =head1 CONFIGURABLE VARIABLES None. =head1 INSTALLATION 1) Make sure this file is named blok.pm and drop it into your blosxom3 plugins folder; 2) Add one line to the handler.entry file -- just _after_ 'Blosxom::read_entry_file' add: 'Blosxom::Plugin::blox::run' (no quotes) NOTE: make sure you save the handler.entry file with unix line-ends; 3) blog on. NOTE: if you are using the "blox" plugin, you should remove or disable blok; its functionality is built into blox. =head1 VERSION 2004-05-30 (v3.0a) - reduce memory o'head by using refs =head1 VERSION HISTORY 2004-05-07 (v0.1a) - ported from blok 0.96 for use with Blosxom 3 2003-09-14 (v0.96) - more thorough 2003-09-09 (v0.95) - LOL! put Win line-end chars in correct order ;-) 2003-08-31 (v0.9) - it's alive =head1 LICENSE this Blosxom Plug-in Copyright 2004, Stu MacKenzie This license is the same as that of Blosxom's at the time of release (3.0+3i).