--- loncom/interface/lonspeller.pm 2004/07/22 16:17:43 1.1 +++ loncom/interface/lonspeller.pm 2004/07/22 19:43:46 1.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Interface routines for Aspell # -# $Id: lonspeller.pm,v 1.1 2004/07/22 16:17:43 www Exp $ +# $Id: lonspeller.pm,v 1.2 2004/07/22 19:43:46 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,12 +33,36 @@ package Apache::lonspeller; use Text::Aspell; use Apache::lonlocal; use strict; +my $speller; -sub getspeller { - my $speller = Text::Aspell->new; +sub markeduptext { + 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.=''; + } + $output.=''.$word.''; + if ($suggestions) { $output.=''; } + $output.=' '; + } + } + return $output; +} + +BEGIN { + $speller = Text::Aspell->new; $speller->set_option('lang','en_US'); $speller->set_option('sug-mode','fast'); - return $speller; +# $speller->set_option('mode','sgml'); } 1;