package MT::Plugin::Dashify; use MT::Template::Context; use MT::Util qw( convert_high_ascii remove_html ); sub dashify { my $s = $_[0]; $s = convert_high_ascii($s); ## convert high-ASCII chars to 7bit. $s = lc $s; ## lower-case. $s = remove_html($s); ## remove HTML tags. $s =~ s!&[^;\s]+;!!g; ## remove HTML entities. $s =~ s![^\w\s]!!g; ## remove non-word/space chars. $s =~ tr! !-!s; ## change space chars to DASHES! ;) $s; } MT::Template::Context->add_global_filter('dashify', \&dashify);