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

How can I highlight more than one occurrence of a match? #107

Open
icarojerry opened this issue Jun 2, 2020 · 11 comments
Open

How can I highlight more than one occurrence of a match? #107

icarojerry opened this issue Jun 2, 2020 · 11 comments

Comments

@icarojerry
Copy link

icarojerry commented Jun 2, 2020

Supposing I have a text like:

  • "Google Chrome is a cross-platform web browser developed by Google."

And use #:~:text=google, only the first occurrence is highlighted, while I would like to highlight all occurrences.

All the text is in the same context and fragment.

Is it possible to do that?

@bokand
Copy link
Collaborator

bokand commented Jun 3, 2020

There's no way to specify "highlight all" but you can specify multiple instances. In your example:

#:~:text=Google-,Chrome&text=browser%20developed%20by-,Google

Would do the trick.

@icarojerry
Copy link
Author

icarojerry commented Jun 3, 2020

I know that, I am using this way for some cases.
But for example, if you access this link:
https://en.wikipedia.org/wiki/Google_Chrome#:~:text=google

Only the first word "Google" is selected, however if you search CTRL+F for the word "Google", all occurrences will be highlighted.

I would like to simulate this effect. Is there any intention in the project for this to be implemented?
Could have a prefix to indicate highlight all occurrences, like "text=~Google" or "text=*Google*"

Thanks for the answer,

@bokand
Copy link
Collaborator

bokand commented Jun 10, 2020

There's no current intention to do that but it's an interesting feature request and could be considered in the future.

Do you have a use case that could be used to motivate it?

@icarojerry
Copy link
Author

icarojerry commented Jun 10, 2020

Yes I have. I work on a research site with long texts. When a user opens one of the results, I send the matches at the URL to keep the highlights in the text, without having to process the search again.

But, look these cases:

  1. Using #:~:text=azimute
    image

  2. Using Ctrl + F -> azimute
    image

@ratibus
Copy link

ratibus commented Jun 15, 2020

Hi

Indeed multiple matches support could be used to highlight some data in tables when we know a pattern but not the specific data, when we create the link.
For example, imagine a table with daily data and a column "date", formatted like yyyy-mm-dd. If I want to highlight the rows of every day of June, I could send the following fragment : #:~:text=-06-

Text being a regexp could also offer many more usage :)

@DavidGP
Copy link

DavidGP commented Feb 13, 2023

I found a website where a syntax like [URL]?s[]=MySearchTerm&s[]=MyOtherSearchTerm works:

https://www.ipwiki.de/arbeitnehmererfinderrecht:beschraenkte_inanspruchnahme?s[]=inanspruchnahme&s[]=Arbeitgeber&s[]=Diensterfindung

However, this syntax doesn't seem to work anywhere else, so it's probably not a feature of Chrome but a function of that website.

@tomayac
Copy link
Contributor

tomayac commented Feb 13, 2023

However, this syntax doesn't seem to work anywhere else, so it's probably not a feature of Chrome but a function of that website.

It's a website feature of the specific site in question, but you can emulate it using multiple Text Fragments. This is a manual process, though, where you need to hand-craft a link.

@RokeJulianLockhart
Copy link

RokeJulianLockhart commented Feb 15, 2023

#107 (comment)

@icarojerry, potentially, an array system would be the most straight forward method – #:~:text=hello would print all instances, whereas #:~:text=hello[0,2:7] would print position 0, +2, and +3 to +7.

@onurusluca
Copy link

Would love to have this. Any updates?

@ideosyncretic
Copy link

+1 for this

@purpleslurple
Copy link

purpleslurple commented Sep 15, 2024

So 22 year old Quip might work, in a pinch: https://purpleslurple.com/quip.php?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FGoogle_Chrome&text=Google&annotation=Look%20at%20that!%20All%20occurrences%20highlighted.%20%3A)

Another (clearer?) example: https://purpleslurple.com/quip.php?text=Granular%20Addressability%20in%20HTML%20Documents%20-%20ON%20THE%20FLY&url=https%3A%2F%2Fdougengelbart.org%2Fcolloquium%2Fforum%2Fba-unrev-talk%2F0209%2Fmsg00015.html

You could grab: https://github.com/purpleslurple/PurpleSlurple/blob/master/quip.php
and https://github.com/purpleslurple/PurpleSlurple/blob/master/quip-bookmarklet.js and run it from your server (off localhost is handy too), if you don't want it served off PurpleSlurple server.

When I last touched that code you could make multiple selections by simply wash repeat cycle on a given page. For some reason, that now breaks. (Maybe Github sessions have changed? My code hasn't. :)

PurpleSlurple is pretty cool too: PurpleSlurple.com

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

No branches or pull requests

9 participants