/** * Highlight words in text by current query request. * @param string $text * @param string $tag * @param array $properties * @return string */ public function highlightText($text, $tag, array $properties = []) { $queries = explode(' ', $this->query); $dom = new Dom(); foreach ($queries as $query) { $highlight = $dom->{$tag}(function () use($query) { return $query; }, $properties); $text = Str::ireplace($query, $highlight, $text); } return $text; }
/** * Escape quotes * @param string $html * @return string */ public function escapeQuotes($html) { return Str::ireplace(["\"", "'", """], '', $html); }