Live data from Hacker News

Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

chromestory.com

1–10 of 332 posts

Re: Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

#2
Seems very cool!

But the functionality feels like it'd be prone to breakage as new text is added to the document (possible in Wikipedia articles for example). But it'd be super-helpful for search engines as they will have a relatively recent copy of the text, and can auto-generate the links on the backend before showing the search results to the user.

Re: Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

#3
I can't find an RFC about this, but it looks like something similar has been proposed in the past, with a slightly different API.

> In URIs for MIME text/plain documents RFC 5147 specifies a fragment identifier for the character and line positions and ranges within the document using the keywords "char" and "line". Some popular browsers do not yet support RFC 5147.[5] The following example identifies lines 11 through 20 of a text document: http://example.com/document.txt#line=10,20

https://en.wikipedia.org/wiki/Fragment_identifier

Re: Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

#7

Seems very cool! But the functionality feels like it'd be prone to breakage as new text is added to the document (possible in Wikipedia articles for example). But it'd be super-helpful for search engines as they will have a relatively recent copy of the text, and can auto-generate the links on the backend before showing the search results to the user.

I'm on the one hand skeptical of the idea being useful, and on the other acknowledging that emacs' ability to open a file on a line and word is quite useful. (Basically, the results of grep can be directly fed to emacs to jump to the result.)(I'm sure this is not limited to emacs.)

You are right that the link is somewhat time limited. However, tools like emacs and ctags show this can be somewhat worked with. Instead of the very specific links that grep creates, generate one that has a location, but also a small pattern that indicates it. To that end, you could generate a link to the word "breakage" with a selector saying where it is expected. And the browser can then just fudge around that selector to find that word. Or highlight where it was expected.

Re: Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

#8

Seems very cool! But the functionality feels like it'd be prone to breakage as new text is added to the document (possible in Wikipedia articles for example). But it'd be super-helpful for search engines as they will have a relatively recent copy of the text, and can auto-generate the links on the backend before showing the search results to the user.

I'd assume a hash of the content would be included with the link, and if the hash changes, then it would make a best-effort guess at the right location, with a different color highlight indicating that it's a guess. At least that's how I would do it.

Re: Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

#9
Very significant limitation: it only links to the first instance of the target text.

What is the expected behavior if you highlight a second instance of some target text and try to create a link to it? It’s bad that the spec doesn’t discuss it. I can see this happening with short selections, like linking to a single word.

Seems like this could use more thought.

Re: Chrome will Soon Let You Share Links to a Specific Word or Sentence on a Page

#10

Seems very cool! But the functionality feels like it'd be prone to breakage as new text is added to the document (possible in Wikipedia articles for example). But it'd be super-helpful for search engines as they will have a relatively recent copy of the text, and can auto-generate the links on the backend before showing the search results to the user.

As described in the Here is How This will Work section, the implementation is humble. It either scrolls the page to the first instance to the string in the fragment or it scrolls and highlights text included and between two comma-separated strings (commas in the strings themselves would need to be url encoded). If you wanted to scroll to the nth instance of a string, you've have to use the latter format and include more text, making it unique or at least the first instance.

Yes, it would fail if the target text no longer exists in the page but link rot is already commonplace. It would be important for it to ignore DOM elements, it can't fail because the target text crosses two paragraphs or a span.

Post reply on HN