Skip to main content
tin.highlight adds configurable markers around the text that produced the match. A match on pineapple returns '<b>pineapple</b>'. tin.highlight_ansi does the same with ANSI colors for a terminal.

tin.highlight(text [, begin_tag [, end_tag [, query]]])

tin.highlight(text, begin_tag, end_tag, query) → text Returns document text with matched spans wrapped in tags. Highlighting marks exactly the text that produced the match. For a BEFORE b, only the b occurrences that satisfy the relation are wrapped. When query is omitted, the predicate is found anywhere in the same statement, including subqueries, CTEs, and DML (RETURNING, MERGE actions, ON CONFLICT).

Tag placeholders

begin_tag can carry two placeholders that TIN fills in for each highlighted span.
When two matches overlap or touch, they merge into one highlight whose placeholders list every query part involved, so tags never nest or interleave.

tin.highlight_ansi(text [, wrap_to [, query]])

tin.highlight_ansi(text, wrap_to, query) → text Returns document text with ANSI color highlighting for matched spans.

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.