WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
586 stars 43 forks source link

Why can't multiple texts be highlighted on the same page? #252

Closed gurkantuna closed 8 months ago

gurkantuna commented 8 months ago

I liked this feature, but it only evaluates the first text element. For example sent the link in the your Issues tab.

https://github.com/WICG/scroll-to-text-fragment/issues#:~:text=opened

image

Is there any parameter or something else to specify same texts?

tomayac commented 8 months ago

This is working as intended. If you want to link to more than one text fragment, use the syntax as per the article. Here's an example link: https://blog.chromium.org/2019/12/chrome-80-content-indexing-es-modules.html#:~:text=Text%20URL%20Fragments&text=text,-parameter&text=:~:text=On%20islands,%20birds%20can%20contribute%20as%20much%20as%2060%25%20of%20a%20cat's%20diet

gurkantuna commented 8 months ago

Thanks @tomayac but your comment is about the sentences. I was asking about a single word repeated multiple times in the content. For example, the link you posted has seven 'context' words but only one is highlighted. https://blog.chromium.org/2019/12/chrome-80-content-indexing-es-modules.html#:~:text=context

Don't you think this should highlight more than one word?

tomayac commented 8 months ago

The algorithm searches for the first matching instance of the word (or word sequence). As I said, if you want to link to all instances, you'd have to hand-craft the URL so that it includes multiple text fragments separated by &.

gurkantuna commented 8 months ago

@tomayac I'm trying to explain that the algorithm is incomplete, or at least of no use to me in its current form. As far as I understand, this feature is sentence-oriented and offered for short answers of a few words. However, I wanted to use it for both words and sentences, but there is no such option. Therefore you should extend the code to highlight the same word more than once.

I've used this feature on many websites, but I'm having to remove it from all of them after realizing it only works once for the entire content. I'm writing a module myself for a similar feature, and for exampple, for the word 'data', I think the way it should work is below.

search-ezgif com-optimize

tomayac commented 8 months ago

This Issue is essentially asking the same as https://github.com/WICG/scroll-to-text-fragment/issues/107 and should be closed as a duplicate thereof. The feature request is valid, but as stated here and in the linked Issue, currently the only alternative is to manually create multiple text fragments, which may or may not work for all use cases.

gurkantuna commented 8 months ago

@tomayac It's been almost four years since that 😲, but it seems like you still haven't planned it.

I added this feature thinking it would work this way in all the work I do, but now that I've removed it, I have to deal with all my customers now. That's why, as you see, I am writing a module and this unplanned work will take me all day. Sorry but it would be better if you implemented this instead of proposing to close this. Of course, you can close this if you want🤔

bokand commented 8 months ago

I agree with @tomayac - this is a duplicate of #107 so I'll close in favor of that one.

This is a valid feature request but isn't the use case we were targeting when initially designing this feature. As such, it would require some additional thought and consideration (in addition to implementation work in browsers) so isn't something I'm planning to take up in the near term. I'm hoping to merge this feature into the HTML standard. Once that happens feature improvements can happen on this as they do by the usual process in HTML.

gurkantuna commented 8 months ago

This is a valid feature request but isn't the use case we were targeting when initially designing this feature.

@bokand I wrote this in the post above because I predicted this.

As far as I understand, this feature is sentence-oriented and offered for short answers of a few words.

Your answer is more acceptable as it explains the reasons rather than ignoring the problem compared to others. Anyway, I already done my own business.