# Blosxom Plugin: amps
# Author(s): Robert Jones <rjones@devzero.org>
# Version: 1.1
# Documentation: See the bottom of this file or type: perldoc amps

package amps;

# No user configuration needed.

my $cursize=0;
my $active=0;

sub start {
 1;
}

sub story {
 my $story_ref=$_[5];

 $$story_ref=~s/&(?!(?:\#\d+|\#x[\da-fA-F]+|\w+);)/&amp;/g;
}

1;

__END__

=head1 NAME

Blosxom Plugin: amps

=head1 SYNOPSIS

Parses all story text and replaces instances of ampersands (&) with the proper
HTML entity (&amp;) to avoid having to hand-convert URLs for proper
compliance.

=head1 VERSION

1.1

=head1 AUTHOR

Robert Jones <rjones@devzero.org>, http://www.devzero.org

=head1 SEE ALSO

Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/

Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml

=head1 BUGS

This isn't so much a bug as a design limitation, but for simplicity's sake we
avoid entitizing any occurence of ampersand followed by one or more
word-characters; a hash and one or more decimal numbers; OR a hash, an x, and
one or more hexadecimal numbers -- in order to avoid messing up any HTML
entitites already existing in the story body.  In most cases this should be
Good Enough(tm), but it could fail in odd situations.

(Thanks to Nathaniel Irons for pointing out that I was neglecting decimal and
hexadecimal entities, and providing the regex to catch them)

Address any further bug reports to the author.

=head1 LICENSE 

Copyright (c) 2003 Robert Jones <rjones@devzero.org>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
