Skip to content

Conversation

@vezwork
Copy link
Contributor

@vezwork vezwork commented Feb 6, 2026

Description

Adds text fragments to items in search. Example video:

Kapture.2026-02-06.at.12.51.59.mp4

I have attempted to write this code quite defensively so that it will not break things. Its not quite the ideal place for this code since this piece of code can be called multiple time for a single item, but it gets the job done.

Text fragments are well supported and apparently browsers will fall back to id linking if the text fragment is not supported or found (worked in my testing in chrome and safari and firefox on Desktop MacOS Tahoe, e.g. https://en.wikipedia.org/wiki/Dog#Domestication:~:text=blablabla).

@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Feb 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@vezwork vezwork requested review from cderv and cscheid February 6, 2026 18:34
@cscheid
Copy link
Collaborator

cscheid commented Feb 9, 2026

The PR looks good. Just to be clear, this exists in part to improve the situation we have wrt visibility of search results in the page, right?

@cscheid cscheid self-assigned this Feb 9, 2026
@vezwork
Copy link
Contributor Author

vezwork commented Feb 10, 2026

Just to be clear, this exists in part to improve the situation we have wrt visibility of search results in the page, right?

Yes, this will be helpful for all search results, but will be especially helpful once we have tabsets that have behaviour that they switch tabs to reveal specific content in response to browser ctrl+f or text fragment links. I am looking into using the <details> element to create a tabset that supports this. It should work based on my testing across desktop browsers.

@vezwork
Copy link
Contributor Author

vezwork commented Feb 10, 2026

Should we merge this? Whats the next release it will be in? Will it be in a "daily" sort of build before the main release so that we can use it in a build of the quarto.org docs?

@cderv cderv merged commit 7a76706 into main Feb 11, 2026
51 checks passed
@cderv cderv deleted the feature/quarto-search-js-text-fragments branch February 11, 2026 11:08
cderv added a commit that referenced this pull request Feb 11, 2026
@cderv
Copy link
Collaborator

cderv commented Feb 11, 2026

Will it be in a "daily" sort of build before the main release so that we can use it in a build of the quarto.org docs?

Yes I'll build the new prerelease, and we can see effect in quarto.org

@cderv cderv added this to the v1.9 milestone Feb 11, 2026
@cderv
Copy link
Collaborator

cderv commented Feb 11, 2026

1.9.20 has the change

@mcanouil
Copy link
Collaborator

mcanouil commented Feb 11, 2026

@vezwork

Probably worth taking a look at this discussion as it's about text fragments and query parameters in URL.

Especially, the following part which is involving in removing the search text highlighting

  • // function to clear highlighting on the page when the search query changes
    // (e.g. if the user edits the query or clears it)
    let highlighting = true;
    const resetHighlighting = (searchTerm) => {
    if (mainEl && highlighting && query && searchTerm !== query) {
    clearHighlight(query, mainEl);
    highlighting = false;
    }
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants