Topic on Project:Support desk

Eliminating Wiki Markup from Search Results

3
65.122.93.130 (talkcontribs)

Is there any solution to removing Wiki markup from Search results?

76.102.130.155 (talkcontribs)

If you understand how hooks work (and thus were able to define this hook that's really not documented), that might work.

For mere mortals who understand a little php, edit includes/search/SqlSearchResult.php, define the function strip_tags_content (as found in the comments for strip-tag), and then use it on mText:

$clean = $this->strip_tags_content($this->mText);

 if ( $wgAdvancedSearchHighlighting ) {

  return $h->highlightText( $clean, $this->terms );

 } else {

  return $h->highlightSimple( $clean, $this->terms );

 }

This ensures that you're stripping out the HTML before the highlighting is applied (or else that would get stripped out too!). It looks like getTextSnippet is only/mostly used for search results, so hopefully the impact is limited there.

Maybe someone will add mortal-level doc on how to use that Hook, though it's been 9 years since this question was asked, so...

Reply to "Eliminating Wiki Markup from Search Results"