# Highlighter

`Xmf\Highlighter` is a class used to highlight terms in text. It's most common use is highlighting search terms in content.

## Highlighter::apply(*$words*, *$body*, *$pre*, *$post*)

Apply a highlight to any occurrences of *$words* found in the *$body* text, surrounding each with *$pre* in front and *$post* behind. Considers only occurrences of words outside of HTML tags.

*$words* is an array of strings to find and highlight. If it is a string, it is treated as a set of space delimited words and converted to an array of strings.

*$body* is text to which highlight is to be applied.

*$pre* is the markup to be used to start a highlight. By default, it is "".

*$post* is the markup to be used to start a highlight. By default, it is "\</strong>".

The highlighted version of *$body* is returned.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xoops.gitbook.io/xmf-cookbook/reference/highlighter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
