You are here

public static function Utility::formatHighlighting in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::formatHighlighting()
  2. 8 src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::formatHighlighting()
  3. 4.x src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::formatHighlighting()

Changes highlighting tags from our custom, HTML-safe ones to HTML.

Parameters

string|array $snippet: The snippet(s) to format.

Return value

string|array The snippet(s), properly formatted as HTML.

1 call to Utility::formatHighlighting()
SearchApiSolrBackend::getHighlighting in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Extract and format highlighting information for a specific item.

File

src/Utility/Utility.php, line 230

Class

Utility
Provides various helper functions for Solr backends.

Namespace

Drupal\search_api_solr\Utility

Code

public static function formatHighlighting($snippet, $prefix = '<strong>', $suffix = '</strong>') {
  return str_replace([
    '[HIGHLIGHT]',
    '[/HIGHLIGHT]',
  ], [
    $prefix,
    $suffix,
  ], $snippet);
}