Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of Concept: Hide search matches #876

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mgeier
Copy link
Contributor

@mgeier mgeier commented Feb 3, 2020

Unfortunately, the highlighting of search results has been removed in readthedocs/readthedocs.org#6087.

I don't like this, and I think the real problem is that the RTD theme doesn't have a simple way to remove those highlights, like other Sphinx themes have, see #816.

This PR shows a really simple way to add this feature back to the theme.

Once we have this, we can revert the removal of the highlighting, see readthedocs/readthedocs.org#6305.

I'm not interested in the styling (can somebody else please do that?), I just want to demonstrate a very simple way to get this functionality.

The relevant CSS selectors would probably be #searchbox .highlight-link for the <p> and #searchbox a (or #searchbox p a?) for the link itself.

I think it makes sense to add the "Hide Search Matches" link close to the search text field, but if desired, it could be placed anywhere be simply adding a <div id="searchbox"></div>. That's all there's to it.

Please note that this does not remove ?highlight=... from the URL. Such a feature, if desired, should be implemented in Sphinx itself.

What do y'all think about this?

@agjohnson
Copy link
Collaborator

Any reason to continue with this PR with search highlighting back on RTD?

@mgeier
Copy link
Contributor Author

mgeier commented May 3, 2020

Well yes. Highlighting is back (which is great!), but there is still no button or whatever to hide the current highlighting in the RTD theme, right?

But this PR is just a proof of concept, feel free to create a nicer styling.

@YaZko
Copy link

YaZko commented Oct 4, 2020

I am not sure how up to date the current PR is, but I would be very interested in the highlighting being fixed indeed.
More specifically, it currently highlights the searched word in all subsequently visited pages.
As far as I'm concerned, I would prefer highlighting to be altogether disabled: I don't quite ever foresee a use case where I would want the technical term I looked for to find a session be bright yellow for its 30 or so occurrences in the text I'm gonna read.
But if people like it, I would at least appreciate a light way to disable it (ideally, hitting escape for instance) other than manually editing the URL to remove the option.

In particular, @cpitclaudel mentioned on Zulip that it could be easily disabled by editing the following CSS:

.rst-content .highlighted {
    background: #F1C40F;
    display: inline-block;
    font-weight: bold;
    padding: 0 6px;
}

@marxin
Copy link

marxin commented Aug 11, 2021

I would like to support the pull request.
The feature is really missing as one can't easily (URL needs to be adjusted) hide the highlighted text.

@mgeier
Copy link
Contributor Author

mgeier commented Aug 15, 2021

Please note that this does not remove ?highlight=... from the URL. Such a feature, if desired, should be implemented in Sphinx itself.

I've just suggested such a change in sphinx-doc/sphinx#9551.

@ana-borges
Copy link

I would also like to support this PR. The highlighting is extremely annoying for me.

@mgeier
Copy link
Contributor Author

mgeier commented Mar 7, 2022

@YaZko

But if people like it, I would at least appreciate a light way to disable it (ideally, hitting escape for instance)

In the meantime, this has been implemented in Sphinx: sphinx-doc/sphinx#9337

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.

None yet

6 participants