# Album Plugin:	examples/formatting/no_dash
# For info:	'album -plugin_info examples/formatting/no_dash'
# For usage:	'album -plugin_usage examples/formatting/no_dash'
use strict;

sub start_plugin {
  my ($opt) = @_;

  # Setup my hooks
  album::hook($opt,'post_clean_name',\&clean_name);

  return {
    author => 'David Ljung Madison',
    href => 'http://MarginalHacks.com/',
    version => '1.0',
    description => <<DESC
Converts dashes '-' to spaces ' ' for names.
Only converts names based on files (as opposed to captions)
Avoids converting dates "<num>-<num>"
DESC
  };
}

sub clean_name {
  my ($opt, $hookname, $name, $iscaption) = @_;
	return $name if $iscaption;	# Only change if not caption
	# Not a perfect regex, confused by /^-/ /-$/ and /--/, but those
	# are unlikely to begin with.
	$name =~ s|(\D)-(\D)|$1 $2|g;

	# Finish cleaning (since clean_name is now skipped)
	$name =~ s/_/ /g;
	$name =~ s/\./ /g;

	$name;
}

# Plugins always end with:
1;
