version 1.1, 2004/07/22 16:17:43
|
version 1.2, 2004/07/22 19:43:46
|
Line 33 package Apache::lonspeller;
|
Line 33 package Apache::lonspeller;
|
use Text::Aspell; |
use Text::Aspell; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use strict; |
use strict; |
|
my $speller; |
|
|
sub getspeller { |
sub markeduptext { |
my $speller = Text::Aspell->new; |
my $input=shift; |
|
my $output=''; |
|
foreach my $word (split(/\W+/,$input)) { |
|
if ($speller->check($word)) { |
|
$output.=$word.' '; |
|
} else { |
|
my $suggestions=join(' ',$speller->suggest($word)); |
|
&Apache::lonnet::logthis($suggestions); |
|
$suggestions=~s/\'/\\\'/gs; |
|
if ($suggestions) { |
|
$output.='<a href="javascript:alert('."'". |
|
$suggestions."');". |
|
'">'; |
|
} |
|
$output.='<font color="red">'.$word.'</font>'; |
|
if ($suggestions) { $output.='</a>'; } |
|
$output.=' '; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
|
BEGIN { |
|
$speller = Text::Aspell->new; |
$speller->set_option('lang','en_US'); |
$speller->set_option('lang','en_US'); |
$speller->set_option('sug-mode','fast'); |
$speller->set_option('sug-mode','fast'); |
return $speller; |
# $speller->set_option('mode','sgml'); |
} |
} |
|
|
1; |
1; |