Skip to content

renderMatches

Official

Render the matches of a search.

Import:

import { renderMatches } from 'obsidian';

Example:

renderMatches(document.body, 'foo', [[0, 3]]);

Signature:

function renderMatches(el: DocumentFragment | HTMLElement, text: string, matches: SearchMatches | null, offset: number | undefined): void

Parameters:

ParameterTypeDescription
elDocumentFragment | HTMLElementThe element to render the matches to.
textstringThe text to render the matches to.
matchesSearchMatches | nullThe matches to render.
offsetnumber | undefinedThe offset to render the matches to.

Returns: void

Example:

renderMatches(document.body, 'foo', [[0, 3]]);