Search Highlight Demo
About This Demo
This site demonstrates search highlighting improvements in Quarto. When you navigate to a page with a ?q=term parameter in the URL, matching terms are highlighted with a yellow background. This is the same mechanism used when you click a search result in the Quarto search box.
Recent improvements include persistent highlights (PR #13442), tab activation for search matches (PR #14053), and cross-node highlighting that works when a search term spans across HTML element boundaries like bold text, inline code, or syntax-highlighted spans (PR #14080).
How to Test
Direct URL highlighting (?q=)
Try these links to see search highlighting in action:
- Pandas page with “data” highlighted
- Visualization page with “chart” highlighted
- Modeling page with “regression” highlighted
These use the ?q=term URL parameter, which triggers JavaScript-based <mark> highlighting on the destination page. The highlights persist until you navigate away or change the search query.
Through the search box
- Click the search icon in the navbar (or press
S) - Type a term like “regression”
- Click on one of the search results
The destination page should scroll to the matching content with JS <mark> highlights (yellow background on matching terms).
The Bug
In previous versions of Quarto, search highlights were cleared almost immediately. Two issues contributed:
The Fix
PR #13442 by @jtbayly removed the scroll-based highlight clearing entirely. Highlights now persist until the user navigates away or changes the search query. PR #14049 adds Playwright test coverage for the expected behavior.
Search & Tab Activation
Building on the highlight fix, PR #14053 automatically activates tabs that contain matching content. When a search result points to content inside an inactive tab, the tab is activated so the highlighted match is visible. This works for ungrouped tabs, grouped tabs (overriding localStorage preferences), and nested tabsets.
See the Tabsets demo page for interactive examples, or try these links directly:
- Inactive tab activation — activates Tab Beta
- Nested tab activation — activates both outer and inner tabs
- Grouped tab override — Python activates despite R preference
Cross-Node Highlighting
PR #14080 by @vezwork fixes search highlighting when a match spans across HTML element boundaries. Previously, if you searched for “bold text” and the page contained <strong>bold</strong> text, only one part would highlight. Now the highlighting correctly wraps across node boundaries.
See the Cross-Node demo page for interactive examples, or try these links directly:
- Bold + plain text — highlight spans a
<strong>boundary - Inline code + text — highlight spans a
<code>boundary - Multiple code spans — highlight spans 3 nodes
- Italic + plain text — highlight spans an
<em>boundary
Content for Searching
This site includes several pages with data science content to provide realistic search targets. Each page covers a different topic — data manipulation with pandas, data visualization, and statistical modeling — with enough prose to exercise the search and highlight functionality across multiple pages.