+ # Remove any html from text to be indexed.
+ # TODO: This removes html that is in eg, a markdown pre,
+ # which should not be removed.
+ if (! defined $scrubber) {
+ eval q{use HTML::Scrubber};
+ error($@) if $@;
+ $scrubber=HTML::Scrubber->new(allow => []);
+ }
+ my $toindex=$scrubber->scrub($params{content});
+
+ # Take 512 characters for a sample, then extend it out
+ # if it stopped in the middle of a word.
+ my $size=512;
+ my ($sample)=substr($toindex, 0, $size);
+ my $next=substr($toindex, $size++, 1);
+ while ($next !~ /\s/) {
+ $sample.=$next;
+ $next=substr($toindex, $size++, 1);
+ }
+ $sample=~s/\n/ /g;
+