--- acronym.pl.orig Fri May 21 10:34:43 2004 +++ acronym.pl Fri May 28 17:17:34 2004 @@ -14,6 +14,7 @@ # # If you modify this code please let me know and I'll try to incorporate the changes into Acronym # +# modified by Jacques Distler to add support 9/2003. package MT::Plugins::Acronym; @@ -44,6 +45,8 @@ my ($str, $param, $ctx) = @_; my %ACRONYM = acronym_load("acronym.db"); + my %ABBR = acronym_load("abbr.db"); + my %acronym_used = (); my $tokens = acronym_tokenize($str); my $acronym_subst_out = ""; @@ -51,8 +54,8 @@ my $acronym_subst_changed = 0; my $acronym_tags = "(a|embed|object|acronym|abbr|dfn|code|math)"; - my $acronym_text_start = '(\s|^|,|\.|\(|\/|-|:)'; - my $acronym_text_end = '(\s|$|,|\.|\)|\/|-|:|\'|\?|\!)'; + my $acronym_text_start = '(^|\W)'; + my $acronym_text_end = '($|\W)'; foreach my $token (@$tokens) { if ($token->[0] eq 'tag') { @@ -63,10 +66,17 @@ } } else { if (!$acronym_subst_intag) { - if ($token->[1] =~ /$acronym_text_start([A-Z0-9]+)$acronym_text_end/) { + if ($token->[1] =~ /$acronym_text_start(\w+)$acronym_text_end/) { foreach my $key (keys %ACRONYM) { my $s = $ACRONYM{$key}; - if ($token->[1] =~ s/$acronym_text_start$key$acronym_text_end/$1$key<\/acronym>$2/g) { + if ($token->[1] =~ s/$acronym_text_start$key$acronym_text_end/join("","$1$key<\/acronym>$2")/ge) { + $acronym_subst_changed = 1; + } + } + foreach my $key (keys %ABBR) { + my $s = $ABBR{$key}; + if ($token->[1] =~ s/$acronym_text_start$key$acronym_text_end/join("","$1$key<\/abbr>$2")/ge) { + $acronym_subst_changed = 1; } }