Class

ExactPhraseHighlighter

ExactPhraseHighlighter(highlightFunction)

Highlights exact-phrase matches found in a verse's searchable text nodes.

Match positions are calculated by VerseSearch against the concatenated text of those nodes. Each position is mapped back to one or more nodes, allowing a phrase to span inline markup without replacing the surrounding elements. The first segment of each match is marked for result navigation; subsequent segments remain highlighted but are not separate results.

Constructor

# new ExactPhraseHighlighter(highlightFunction)

Parameters:
Name Type Description
highlightFunction function

Returns highlight markup; the boolean indicates whether the segment starts a new occurrence.

View Source frontend/components/tab_search/exact_phrase_highlighter.js, line 30

Methods

# highlightOccurrences(nodes, occurrences, searchLength)

Replaces matched text nodes with wrappers containing highlighted segments. Other text and surrounding markup are preserved. The wrappers also allow the tab-search reset logic to remove the highlights.

Parameters:
Name Type Description
nodes Array.<Text>

Searchable text nodes in document order.

occurrences Array.<number>

Ascending, non-overlapping match offsets in the concatenated node text, measured in UTF-16 code units.

searchLength number

Match length in UTF-16 code units.

View Source frontend/components/tab_search/exact_phrase_highlighter.js, line 49